PeytonRG/BootstrapToaster

Queue

spkesDE opened this issue · 6 comments

Is there are Queue system in place?
Also is there a action for the close? So I can ajax that the notfication/toast is read?

Best regards :)

There is no queue system, but that is a very good idea. As for knowing when a toast closes, I could potentially return a reference to the toast when it's created (currently it's a void function), and you could use the Events feature from Bootstrap itself to integrate that feature yourself. The one I personally use for this library is hidden.bs.toast

Added a simple queue to your toaster. It may need modfication but it works for me now

let queue = [];
...
create(...)
...
 if (currentToastCount >= maxToastCount){
            queue.push({t: toast, time: timeout});
        } else {
            Toast._render(toast, timeout);
        }
...
_render(...)
....
toast.addEventListener('hidden.bs.toast', () => {
            TOAST_CONTAINER.removeChild(toast);
            currentToastCount--;
            if(queue.length !== 0 && currentToastCount <= maxToastCount){
                let obj = queue.shift();
                Toast._render(obj.t, obj.time);
            }
        });

I'll see about implementing that myself, as well as what I suggested for the actions you asked about.

Give 5.1.0 Beta 2 a try. I implemented a queue that's very similar to yours above. Heads up, I changed up the signature of the create and configure functions and switched to developing in TypeScript, so to get a feel for it I recommend looking in bootstrap-toaster.ts rather than bootstrap-toaster.js.

I plan on making shims for the previous signatures to still work, just haven't done that yet. And if you use Bootstrap 4, I'll be making these changes as a 4.1.0 shortly after I'm done with 5.1.0

5.1.0 is now out, but I'll keep this issue open until I release 4.1.0 as well

4.1.2 is released, so now all supported versions include the queue