How to limit number of Notify messages?
-
What is the best way to limit the number of Notify dialogs that are displayed on a screen?
It would be nice to have:
- Global control (max # that can be displayed at a single time)
- Ability to scope/group them, by name/id
Perhaps for now I could do something like:
var notifyLimit = 1 var notifies = {} ... createNotify('negative', 'This is a message', 'action1') ... function createNotify(type, message, scope) { if (scope in this.notifies) { // Check limit if (this.notifies[scope].length === this.notifyLimit ) { this.notifies[scope][0].dismiss() delete this.notifies[scope][0] } } let notify = Notify.create({ type: type, message }) this.notifies[scope].push(notify) } ... function clearAllNotfies() { for (scope in this.notifies) { for (var i = 0; i < notifies[scope].length; i++) { notifies[scope][i]].dismiss() } } this.notifies = {} }
btw, I haven’t tested the above, just quickly mocked it up. Also, not even sure Notify.dismiss() works that way