File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed
src/com/react-dynamic-tabs/utils/api Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change
1
+ import helper from '../helper.js' ;
1
2
const Pub_Sub = function ( ) {
2
3
this . _publishers = {
3
- beforeSwitchTab : [ ]
4
- , onChange : [ ]
4
+ onChange : [ ]
5
5
, onLoad : [ ]
6
6
, onDestroy : [ ]
7
7
, onOpen : [ ]
8
8
, onClose : [ ]
9
9
, onSelect : [ ]
10
+ , beforeSelect : [ ]
11
+ , beforeClose : [ ]
12
+ , onInit : [ ]
13
+ , onFirstSelect : [ ]
10
14
} ;
11
15
} ;
12
16
//unSubscribe
@@ -34,13 +38,15 @@ Pub_Sub.prototype.one = function (publisherName, fn) {
34
38
}
35
39
return this ;
36
40
} ;
37
- Pub_Sub . prototype . trigger = function ( publisherName , param , context ) {
38
- if ( this . _publishers . hasOwnProperty ( publisherName ) ) {
41
+ helper . setNoneEnumProps ( Pub_Sub . prototype , {
42
+ trigger : function ( publisherName , context , ...param ) {
43
+ context = context || null ;
44
+ const result = [ ] ;
39
45
const _subscribers = [ ...this . _publishers [ publisherName ] ] ;
40
46
_subscribers . map ( subscriber => {
41
- context ? subscriber . call ( context , param ) : subscriber ( param ) ;
47
+ result . push ( subscriber . apply ( context , param ) ) ;
42
48
} ) ;
49
+ return result ;
43
50
}
44
- return this ;
45
- } ;
51
+ } ) ;
46
52
export default Pub_Sub ;
You can’t perform that action at this time.
0 commit comments