I'm using Truffle (Webpack Box) and watching events on the front end. I'm having to design around ensuring I do not initiate watching for events more than once. Is there a best practice on how to do this? Is there a quick way to tell if an event is already being watched?

1 Answer 1


When you start watching the events with

filter = myInstance.EVENT(filter, additionalFilter, callback)

you can store the returned filter. If you have the filter and your callback didn't run into an error, you can assume that you're watching, otherwise the watching has stopped.

If you want to explicitly stop watching the events, call filter.stopWatching().

  • Thanks, that approach makes sense. Do you know of any issues with testrpc duplicating events? I'm using this approach, and I can tell that I'm not duplicating the event watch, but I'm seeing multiple events of the same pop up.
    – Karen S
    Commented Mar 26, 2018 at 23:19
  • Can you observe the same behaviour with duplicates when you run your code with geth/parity? I am working with ganache-cli 6.1.0 (successor to testrpc) right now and I didn't observe any issues watching events.
    – ivicaa
    Commented Mar 27, 2018 at 5:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.