cristiammercado / ng-event-bus Goto Github PK
View Code? Open in Web Editor NEWRxJS-based message bus service for Angular.
License: MIT License
RxJS-based message bus service for Angular.
License: MIT License
Greetings!
Thanks for this amazing plugin! I was migrating from AngularJS to Angular 9 and was looking for something like this. The only thing I missed so far is the posibility to have and use the event bus key on the callback function.
So for example I have a page where I listen for updates on 2 resources in order to update a badge. And those resources may emit a increase or decrease event. I think it would be better to handle the different logic for increase or decrease bassed on the bus of each event, instead of having multiple listeners, one for each event. This could be done if the suscribe callback could come with an additional parameter with the event bus key.
Thanks in advance and please correct me if I'm wrong or there are better ways to do it (Or it's already implemented and I didn't see it).
WARNING in E:\Imover\src\app\app.module.ts depends on 'ng-event-bus'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies
really nice tool.
Would be interesting to add a BehaviorSubject type subscribe.
Some way to use the async pipe that would return just the data.
If you have an idea on how to handle ether one of these issues but just don't have time to mess with it then let me know and I can see if I can get it working and do a pull request.
this.bus
.on('**')
.pipe(map(message => message))
.subscribe(message => {});
Error:
Argument of type 'import("repo/node_modules/rxjs/internal/types").OperatorFunction<unknown, unknown>' is not assignable to parameter of type 'import("repo/node_modules/ng-event-bus/node_modules/rxjs/internal/types").OperatorFunction<unknown, unknown>'.
Types of parameters 'source' and 'source' are incompatible.
Type 'import("repo/node_modules/ng-event-bus/node_modules/rxjs/internal/Observable").Observable<unknown>' is not assignable to type 'import("h:/Repositories/USCore/appraiser-portal/node_modules/rxjs/internal/Observable").Observable<unknown>'.
The types of 'source.operator.call' are incompatible between these types.
Type '(subscriber: import("repo/node_modules/ng-event-bus/node_modules/rxjs/internal/Subscriber").Subscriber<any>, source: any) => import("repo/node_modules/ng-event-bus/node_modules/rxjs/internal/types").TeardownLogic' is not assignable to type '(subscriber: import("repo/node_modules/rxjs/internal/Subscriber").Subscriber<any>, source: any) => import("repo/node_modules/rxjs/internal/types").TeardownLogic'.
Types of parameters 'subscriber' and 'subscriber' are incompatible.
Type 'import("repo/node_modules/rxjs/internal/Subscriber").Subscriber<any>' is not assignable to type 'import("repo/node_modules/ng-event-bus/node_modules/rxjs/internal/Subscriber").Subscriber<any>'.
Property 'isStopped' is protected but type 'Subscriber<T>' is not a class derived from 'Subscriber<T>'.ts(2345)
This error appears on the .pipe(map
line. It seems the ng-event-bus observable type returned from .on
is not what .map
expects, which is the rxjs observable type. I have tried this with other operators and they also have the same error.
I am on Angular 10.
When using code:
eventBus.on('app:start').subscribe((message)=>{ console.log(message); //will receive 'started' only });
should i unsubscribe?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.