Skip to content

Commit 6520fa4

Browse files
committed
remove beforeSwitchTab publisher and add a few
publishers
1 parent 68f12bb commit 6520fa4

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/com/react-dynamic-tabs/utils/api/pub_sub.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
import helper from '../helper.js';
12
const Pub_Sub = function () {
23
this._publishers = {
3-
beforeSwitchTab: []
4-
, onChange: []
4+
onChange: []
55
, onLoad: []
66
, onDestroy: []
77
, onOpen: []
88
, onClose: []
99
, onSelect: []
10+
, beforeSelect: []
11+
, beforeClose: []
12+
, onInit: []
13+
, onFirstSelect: []
1014
};
1115
};
1216
//unSubscribe
@@ -34,13 +38,15 @@ Pub_Sub.prototype.one = function (publisherName, fn) {
3438
}
3539
return this;
3640
};
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 = [];
3945
const _subscribers = [...this._publishers[publisherName]];
4046
_subscribers.map(subscriber => {
41-
context ? subscriber.call(context, param) : subscriber(param);
47+
result.push(subscriber.apply(context, param));
4248
});
49+
return result;
4350
}
44-
return this;
45-
};
51+
});
4652
export default Pub_Sub;

0 commit comments

Comments
 (0)