johnnyb / Eventually

A library for event-based programming to make Arduino programming more fun and intuitive
MIT License
190 stars 41 forks source link

removeListener #9

Open stephensaid opened 4 years ago

stephensaid commented 4 years ago

Hi,

Hi, would I remove a particular listener, please? Thanks Stephen

stephensaid commented 4 years ago

Hi guys, Just noticed my error in my question!

How would I remove a particular listener, please? I have a number of listeners that needs to stay on but have a particular one which needs to be either stopped or reset.

Thanks

szabo-roland commented 4 years ago

Hello!

I think you can use removeListener on the context manager. Note, that if you want to use it, you have to keep a reference to the event listener in a variable. So instead of doing this: mgr.addListener(new EvtPinListener(...); you will write EvtPinListener * myEvtPinListener = new EvtPinListener(...); mgr.addListener(myEvtPinListener); and when you want to remove it, you just write mgr.removeListener(myEvtPinListener)