GithubHelp home page GithubHelp logo

cristiammercado / ng-event-bus Goto Github PK

View Code? Open in Web Editor NEW
48.0 1.0 7.0 1.34 MB

RxJS-based message bus service for Angular.

License: MIT License

TypeScript 52.44% JavaScript 6.19% HTML 17.98% SCSS 23.38%
angular rxjs message-bus event-bus event

ng-event-bus's People

Contributors

cristiammercado avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

ng-event-bus's Issues

Suggestion: Include Event Bus Key on Callback

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).

Feature Request

really nice tool.

  1. Would be interesting to add a BehaviorSubject type subscribe.

    • Currently when loading a new component you have to add a subscript and also a cast to get the info and on the receiving end you have to add a subscript to listen for the request to cast that data.
    • looking at the source I know this would be a crazy to get working but think of how cool it would be.
  2. 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.

Cannot use RxJS operators

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.

Need to unsubscribe?

When using code:
eventBus.on('app:start').subscribe((message)=>{ console.log(message); //will receive 'started' only });
should i unsubscribe?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.