Pub/Sub Service for Angular 7 abd above
A simple publisher/subscriber service. This repository is forked from angular-pubsub and the only reason I changed it was to use RXJs version 6 and above. and updated the angular packages.
All credit goes to the owner and contributers of angular-pubsub repo.
- Import service in your codes or download via npm or bower.
npm i --save angular7-pubsub
- Add module bundle to imports in your application.
...; // <= HERE...
- And import service wherever you want
PubSubService.$pub(event: string, eventObject?: any): void
Publish event to all subscriber.
PubSubService.$sub(event: string): Observable
Subscribe to channel.
$sub method have one bug. RxJS Subscriber call subscribe method on start like Angular 1.x $scope.$watch.
Build the source
Follow the steps to run the tests and build the source code.
npm installnpm testnpm run build
Commands above will generate the ready to use bundles under the