Skip to content

JeffXiao/reactiveSrvc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

reactiveSrvc

An AngularJS based subscribe/broadcast service using reactive design pattern

In general, it is not efficient in terms of performance to use $rootSceop to send and receive message, such as: $rootScope.$emit $rootScope.$on

Here I use an AngularJS service to implement a reactive design pattern:

// subscribe the service when button1 is clicked reactiveSrvc.subscribe('button1Clicked', function () { $scope.button1Count++; });

// notify the service that button1 is clicked $scope.button1Clicked = function () { reactiveSrvc.notify('button1Clicked'); };

Here is the demo: Demo

It is very simple to use. Enjoy!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages