This repository was archived by the owner on Dec 19, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +16
-14
lines changed
Expand file tree Collapse file tree 2 files changed +16
-14
lines changed Original file line number Diff line number Diff line change @@ -14,18 +14,20 @@ var _rx2 = _interopRequireDefault(_rx);
1414function events ( ) {
1515 var evs = arguments . length <= 0 || arguments [ 0 ] === undefined ? [ ] : arguments [ 0 ] ;
1616
17- var streams = evs . reduce ( function ( res , eventName ) {
18- res [ eventName ] = new _rx2 [ 'default' ] . Subject ( ) ;
19- return res ;
20- } , { } ) ;
21-
2217 return {
2318 componentWillMount : function componentWillMount ( ) {
24- Object . assign ( this , streams ) ;
19+ var streams = evs . reduce ( function ( res , eventName ) {
20+ res [ eventName ] = new _rx2 [ 'default' ] . Subject ( ) ;
21+ return res ;
22+ } , { } ) ;
23+
24+ Object . assign ( this , streams , { __streams : streams } ) ;
2525 } ,
2626 componentWillUnmount : function componentWillUnmount ( ) {
27+ var _this = this ;
28+
2729 evs . forEach ( function ( ev ) {
28- return streams [ ev ] . onCompleted ( ) ;
30+ return _this . __streams [ ev ] . onCompleted ( ) ;
2931 } ) ;
3032 }
3133 } ;
Original file line number Diff line number Diff line change 11import Rx from 'rx'
22
33export default function events ( evs = [ ] ) {
4- var streams = evs . reduce ( function ( res , eventName ) {
5- res [ eventName ] = new Rx . Subject ( )
6- return res
7- } , { } )
8-
94 return {
105 componentWillMount ( ) {
11- Object . assign ( this , streams )
6+ var streams = evs . reduce ( function ( res , eventName ) {
7+ res [ eventName ] = new Rx . Subject ( )
8+ return res
9+ } , { } )
10+
11+ Object . assign ( this , streams , { __streams : streams } )
1212 } ,
1313 componentWillUnmount ( ) {
14- evs . forEach ( ( ev ) => streams [ ev ] . onCompleted ( ) )
14+ evs . forEach ( ( ev ) => this . __streams [ ev ] . onCompleted ( ) )
1515 }
1616 }
1717}
You can’t perform that action at this time.
0 commit comments