Remove all listeners #1461
sammachin
started this conversation in
Feature requests (vote via thumbs up)
Replies: 3 comments
-
Are you looking for a convenient way to remove listeners you've added? Or to disable listeners installed by default cluster implementations? For the former ObserverGroup might be useful. It'll remove one or more listeners without specifying them explicitly |
Beta Was this translation helpful? Give feedback.
0 replies
-
yes its for removing listeners I added, any more notes on ObserverGroup? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Sure, it works like this: import { ObserverGroup } from "@matter/main";
// create a device
const observers = new ObserverGroup();
observers.on(device.events.identify.startIdentifying, () => console.log("Started identifying"));
observers.on(device.events.identify.stopIdentifying, () => console.log("Stopped identifying"));
// do some stuff
observers.close();
// Listeners added above are removed |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'd like to be able to call removeAllListeners() for an event without specfying a function and have it remove all listeners for that event.
Beta Was this translation helpful? Give feedback.
All reactions