Stabzs / Angular2-Toaster

Angular2-toaster is an asynchronous, non-blocking Angular Toaster Notification library
MIT License
334 stars 93 forks source link

Not working in angular 16.0 #272

Open madhurakhal opened 1 year ago

madhurakhal commented 1 year ago

image

selangley-wa commented 1 year ago

It will not work in Angular 16 until such time that the library is migrated to build with Ivy. With Angular 16, they decided to finally remove all compatibility with the older type of modules using the View engine.

https://angular.io/guide/update-to-version-16#angular-compatibility-compiler-ngcc-has-been-removed

Angular Compatibility Compiler (ngcc) has been removed

The Angular Compatibility Compiler (ngcc) was a build tool that facilitated compatibility between Angular's previous compiler and rendering architecture (View Engine) and its new architecture (Ivy).

View Engine was removed in Angular v13, and v16 finally removes ngcc. As a result, Angular libraries built with View Engine cannot be used in Angular v16+.

If this package does not get updated to support Ivy, you will need to remove this library for any project using Angular 16 or later.

Possible alternative libraries are:

https://www.npmjs.com/package/ngx-toastr https://www.npmjs.com/package/@sweetalert2/ngx-sweetalert2 https://material.angular.io/components/snack-bar/overview The next one is not distributed as a library but as tutorial/example of how to do it yourself, but focused on just "alerts" https://jasonwatmore.com/angular-15-free-course-5-alerts-home-page

Update: There are now two forks of this project that have both released npm packages that supposedly work with Angular 16 and Ivy:

https://github.com/ShacharHarshuv/Angular2-Toaster https://www.npmjs.com/package/angular2-toaster-2

https://github.com/dmkachko/Angular2-Toaster https://www.npmjs.com/package/@dkachko/angular2-toaster

@Stabzs

selangley-wa commented 6 months ago

After spending some time looking at each of the alternative libraries I listed above, I think: https://www.npmjs.com/package/ngx-toastr provides the closest to a "drop-in replacement" for Angular2-Toaster

It has a somewhat different API, but most of the same functionality and configuration options as Angular2-Toaster. Additionally, it appears to be well-maintained with regular releases tracking the pace of Angular development and with a number of developers contributing to the project.

Depending on which version you use, you may want to take a look at the answers to this stack overflow question for guidance: https://stackoverflow.com/questions/72473119/place-toastr-toasts-in-container-in-specific-component

SweetAllert2 and Angular Materials Snackbar component both provide toaster-like functionality, but that is not their main focus. Also, they both explicitly state that they do not support displaying more than one toast on the screen at once.

https://github.com/sweetalert2/sweetalert2/issues/2383 Display multiple toasts? #2383

https://github.com/angular/material/issues/2799 $mdToast is supported multiple 'toast' at same time? #2799