Ngx-toastr: preventDuplicates as individual toast settings

Created on 20 Jul 2017  路  6Comments  路  Source: scttcper/ngx-toastr

Hi @scttcper ,

I need "preventDuplicates" as individual toast setting as I have 2 different toastr messages in my application.

One is with "positionClass": "toast-bottom-right" and the other is with "positionClass": "toast-top-full-width".

For the "positionClass": "toast-top-full-width" I need "preventDuplicates" : true and for the "positionClass": "toast-bottom-right" I need "preventDuplicates" : false.

Can you help me in this?

Thanks,
Hari

Most helpful comment

I don't think we're going to support this since the original angular-toastr doesn't either. I've just released 5.3.1 which might help you. It makes the toastrService.isDuplicate(message) public. You could call this before the show toast for those specific toasts.

All 6 comments

Can you debounce the events in your application using debounce from lodash or RxJS?

Hi @cmckni3 ,

I am using underscore.js and I can use http://underscorejs.org/#debounce to debounce.
But what do you mean by debounce the events in your application ?

Correct me if I'm wrong. I assume you are using some sort of event to trigger toast messages and they can possibly happen within a certain amount of time of each other. I am not sure about your required use case.

I don't believe this should be a responsibility of ngx-toastr but maybe @scttcper can chime in with an opinion.

Hi @cmckni3 ,

I am using "positionClass": "toast-top-full-width" toastr message for displaying HTTP service errors. This should not display duplicate messages.

I cannot apply the global setting as this will impact my second toastr message which can display duplicate messages and these messages are atmosphere push message from server.

Thanks,
Hari

I don't think we're going to support this since the original angular-toastr doesn't either. I've just released 5.3.1 which might help you. It makes the toastrService.isDuplicate(message) public. You could call this before the show toast for those specific toasts.

@scttcper cool

@harikrishnan-u01 That sounds like a good use case for using RxJS and Observables to prevent duplicates.

Was this page helpful?
0 / 5 - 0 ratings