-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME
69 lines (51 loc) · 1.94 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Goals
-----
events4js is a javascript events framework
designed for require() usage
write by @waxzce
examples and test avaible into the tests directory
API doc is generated by yuidoc into docs/output/pathjs_docs/index.html
build directory contain usable build
feel free to contribute, comment or ask :-)
Under MIT licence
HOW TO USE
----------
The goal of event4js is give the possibility of produce events from any object.
Create an EventProducer :
__________________________________________________________________________________________
var MyClass = (function () {
var e4js = require('events4js');
Some_Event_Producer = function () {
this.initialize();
}
var p = Some_Event_Producer.prototype = new e4js.EventProducer();
p.initialize_event = p.initialize;
p.initialize = function () {
this.initialize_event();
}
return Some_Event_Producer;
})();
__________________________________________________________________________________________
Some tricks :
=> autoLaunch
The autolaunch is a way to fire an event after another. For example fire "end" after "success" or "error"
Just give some config to the initialize_envent method :
__________________________________________________________________________________________
this.initialize_event({
autoLaunch: {
'end': ['success', 'error']
}
});
__________________________________________________________________________________________
=> waitFor
The wait for allow to fire an event after a list of events fire. For example fire "tree" if "one" and "two" have been fire.
Just give some config to the initialize_envent method :
__________________________________________________________________________________________
this.initialize_event({
waitFor: {
'tree': ['two', 'one'],
'l': ['m', 'n']
}
});
__________________________________________________________________________________________
Other examples in the tests directory