-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
Hi @futomi
thanks for this nice library!
Here's a quick feature request, because I am missing a quick callback to allow for monitoring the progress of a discovery:
Since there is a delay until the discovery is parsed and the promise resolved, I added a callback function (progress), which is called whenever a new device is found. This allows updating the UI (or take another action) as soon as a device is dicovered (instead of waiting until the promise resolved).
Would you be open to add something like that into the library? (If you like, I can send a pull-request).
The addition would be very simple to implement (see below) and called like this:
mDnsSd.discover({
name: '_airplay._tcp.local',
progress: (device) => { // add a callback-function <---
console.log('progress called with device', device?.address);
},
}).then((device_list) => {
// ...
}).catch((error) => {
console.error(error);
});
Changes:
in dns-sd.js:: ~ line 247:
if('progress' in params) {
const v = params['progress'];
if(typeof (v) !== 'function') {
return { error: new Error('`progress` must be a function.') };
}
p['progress'] = v;
}
in dns-sd.js:308:
const progress = params['progress'];
in dns-sd.js:320:
if (progress) {
progress(device);
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels