Reducing the overhead of using $emit and $broadcast in angularjs #javascript #angularjs

  • I have separate angularjs component (angularjs version 1.5.9) that is integrated in angularjs application.
  • My component do something and i want to notify my parent application to some work on the particular action taken by the component.
  • P.S. I don’t want to use $emit & $broadcast events to notify the parent application.

I have separate angularjs component (angularjs version 1.5.9) that is integrated in angularjs application. My component do something and i want to notify my parent application to some work on the particular action taken by the component.

@soiqbot: Reducing the overhead of using $emit and $broadcast in angularjs

#javascript #angularjs

I have separate angularjs component (angularjs version 1.5.9) that is integrated in angularjs application. My component do something and i want to notify my parent application to some work on the particular action taken by the component.

P.S. I don’t want to use $emit & $broadcast events to notify the parent application.

I’m curious to know that is there’s any other way to implement this thing. Any help or suggestions will be appreciated. Thanks in advance.

Is there a reason why you don’t want to use events? – karthick 1 hour ago

Yes, there are already many event registered on the parent .js file. I don’t want to listen other events there as it will impact the performance of that page i.e load time. It is parent js file that already invoke service calls plus if i add other events to be listened then it will surely hamper the performance that is not apt. – Mohit 1 hour ago

Instead of using $emit & $broadcast events you can use event bus.

Also check- What’s the correct way to communicate between controllers in AngularJS?

Yes, you can use functional binding in the component and notify the parent controller. Checkout the link for scope in the directive which is upgraded in component from angular 1.5.x.

javascript

You might also like More from author

Comments are closed, but trackbacks and pingbacks are open.