Reputation: 1010
I need a central, singleton Angular 2 event aggregator for cross component/module communication.
Is there an event aggregator for Angular 2 (7.3.6), that is "ready-to-go" and which can be installed with npm?
I have seen few custom implementations, but I could not find any "official" or "widely accepted" node module for this purpose.
Upvotes: 1
Views: 664
Reputation: 5436
There two types of implementations that I know of and have used in projects. Depending on your requirements, both may fit your request:
A basic "bus" style lib, enables exchanging messages / events between components or among the whole of your application.
https://www.npmjs.com/package/ngx-message-bus
Depending on the scale of your application (read: if it's rather big), you may be interested in Redux-style libraries like NGRX, NGXS or Akita. Strictly speaking, these libs are not purely messaging systems, but state management projects. Redux has a lot of advantages (immutable state, traceable actions and state changes) but usually also comes with a learning curve.
Upvotes: 4