Phlox Midas
Phlox Midas

Reputation: 4349

What's the stream equivalent to on.event.remove

I have some old code I'm updating and the cleaner isn't picking it up.

I succeeded in changing the following:

document.on.mouseOut.add(onDocumentMouseOut);

to

document.onMouseOut.listen(onDocumentMouseOut);

but I don't know how to translate this:

document.on.mouseOut.remove(onDocumentMouseOut);

What's the stream equivalent of remove?

Upvotes: 1

Views: 108

Answers (1)

Greg Lowe
Greg Lowe

Reputation: 16261

Keep a reference to the StreamSubscription object returned by listen(), and call the cancel() method on it.

// Add a handler
var subscription = document.onMouseOut.listen((e) => print('oi'));

// Remove the handler
subscription.cancel();

Upvotes: 3

Related Questions