wemo-client icon indicating copy to clipboard operation
wemo-client copied to clipboard

How to unsubscribe from discovery?

Open Sawtaytoes opened this issue 3 years ago • 1 comments

When calling wemoClient.discover, how do I unsubscribe?

Sawtaytoes avatar Nov 23 '20 00:11 Sawtaytoes

hmm, it currently isn't possible i could think of a couple of solution to solve this

  • One would be to use AbortSignal/AbortController
  • Another would be to return a stop function
const ctrl = new AbortController()
const {signal} = ctrl
wemoClientDiscover(cb, { signal })

const listener = wemoClientDiscover(cb)
listener.stop()

it would also be cool to do something like

for await (const device of wemoClientDiscover({ signal })) {
  // ...
}

jimmywarting avatar Jan 26 '22 23:01 jimmywarting