https://github.com/denieler/angular-sequence-events
Sequential code and chained execution of events, handlers, etc.
https://github.com/denieler/angular-sequence-events
angular events functional-programming library
Last synced: 8 months ago
JSON representation
Sequential code and chained execution of events, handlers, etc.
- Host: GitHub
- URL: https://github.com/denieler/angular-sequence-events
- Owner: denieler
- Created: 2015-08-05T21:16:54.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-10-15T18:39:56.000Z (about 8 years ago)
- Last Synced: 2025-03-01T00:07:34.292Z (9 months ago)
- Topics: angular, events, functional-programming, library
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Angular Sequence Events
Library allows you to make sequential execution of events, handlers, broadcasts, etc. in next way:
````js
var sequence = new Sequence(this.$scope);
sequence
.wait('userAction-1')
.wait('userScroll-1', self.scrollManager)
.broadcast('userFinished-Scroll-1-Action')
.wait('userAction-2')
.wait('userScroll-2', self.scrollManager)
.exec(myFunction)
.broadcast('userFinished-Scroll-2-Action')
.wait('userAction-3')
.run({
loopLastAction: true
});
````
Library now works for AngularJS, using its `$scope` events mechanism.
Lib is in ES2015 syntax, so if you need it in ES5, please use babel to transpile.
# Action types
Library have now 3 types of functions:
`wait (eventName)` - to wait when event has been executed
`exec (funciton)` - executes some code
`broadcast (eventName)` - broadcasts the event
# Mechanism
When you create the sequence you are starting some journey. In which you could use 3 types of functions: wait, exec, broadcast.
example:
````js
var sequence = new Sequence(this.$scope);
sequence
.wait('userAction-1')
.wait('userScroll-1', self.scrollManager)
.run();
````
Here you are waiting for the event `userAction-1` from any angular component, then when event has been fired you are going to the next step - waiting for the event `userScroll-1`. When you pass second parameter in `wait` function it means that you are calling method `userScroll-1` in `self.scrollManager` object and this method is getting callback as parameter. And when callback will be fired from this object next sequence method will be executed.