Closed clytras closed 5 years ago
Hmm the chaining is smthng i think makes this lib nifty.
Is there a way you can adjust how you’re using Uifx. Like adding a delay?
On Nov 11, 2019, at 6:56 PM, Christos Lytras notifications@github.com wrote:
Promisify play method so to be able to catch errors.
To test:
const NofifyAudio = new UIfx('/media/orders_notify.mp3');
NofifyAudio.play().catch(err => console.warn('UIfx play error', err));
// We can now skip the whole message like this: // NofifyAudio.play().catch(() => {}); It should echo our catch console warning instead of the direct DOM error:
UIfx play error DOMException: play() failed because the user didn't interact with the document first. You can view, comment on, or merge this pull request online at:
https://github.com/wle8300/uifx/pull/10
Commit Summary
Promisify play method File Changes
M src/index.js (8) Patch Links:
https://github.com/wle8300/uifx/pull/10.patch https://github.com/wle8300/uifx/pull/10.diff — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.
Of course there is another way to handle this error and ignore it, but if you ask me, chaining is something that belongs to the past; most modern paradigms tend to use functional implementations, but since you've picked the class/object way, then we can just ignore this error, though this way does not give control to the end developer over errors. Will post a new PR.
Promisify play method so to be able to catch errors.
Fixes https://github.com/wle8300/uifx/issues/9
To test:
It should echo our
catch
console warning instead of the direct DOM error: