Open dengue8830 opened 5 years ago
Sure please propose a PR I’ll be happy to take a look :)
On 23 Oct 2019, at 16:36, David Rearte notifications@github.com wrote:
Problem
if i call the notification two or more times consecutively it renders just the first one. If i use a timeout for the second one i get a good behaviour.
Proposal
I'm thinking implement a delayed queue in order to show consecutive calls in a queued way and show them one by one with a timeout. Do you accept a pull request for this?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.
I will try to add this feature next week, by the moment i used this code (if someone find it useful) in my project
This is a resume of the real code
function timeout(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
class NotificationService {
// you can call this one several times
show(notif) {
this.queue.push(notif);
this.evaluateQueue();
}
async evaluateQueue() {
if (!this.queue.length || this.isEvaluationProcessLocked) {
return;
}
this.isEvaluationProcessLocked = true;
// We can use a recursive approach too
while (this.queue.length) {
this._show(this.queue.splice(0, 1)[0]); // the real showNotification api
await timeout(4000); // closeInterval, check docs of this lib
}
this.isEvaluationProcessLocked = false;
}
}
Problem
if i call the notification two or more times consecutively it renders just the first one. If i use a
timeout
for the second one i get a good behaviour.Proposal
I'm thinking implement a
delayed queue
in order to show consecutive calls in a queued way and show them one by one with a timeout. Do you accept a pull request for this?