jimmywarting / wemo-client

JavaScript client library for controlling and subscribing to Wemo Devices
MIT License
132 stars 40 forks source link

How to unsubscribe from discovery? #70

Open Sawtaytoes opened 3 years ago

Sawtaytoes commented 3 years ago

When calling wemoClient.discover, how do I unsubscribe?

jimmywarting commented 2 years ago

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

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 })) {
  // ...
}