@@ -62,9 +62,11 @@ export default class ChannelStore {
6262 onInitChannel = initData => {
6363 const { data, id } = initData ;
6464 const selectorId = id || GLOBAL ;
65- const selectedData = this . store [ selectorId ] ;
65+ console . log ( 'TCL: ChannelStore -> onConnectedFn -> selectorId' , selectorId ) ;
66+ const selectedData = { ...( this . store [ selectorId ] || { } ) } ;
6667 selectedData . init = data ;
6768 selectedData . over = selectedData . over || { } ;
69+ this . store [ selectorId ] = selectedData ;
6870 this . selectorId = selectorId ;
6971 this . subscriber ( ) ;
7072 this . send ( ) ;
@@ -120,20 +122,31 @@ export default class ChannelStore {
120122 ...payload ,
121123 } ) ;
122124
123- _createAction = ( reducer = this . defaultReducer , subId ) => {
125+ _createAction = ( reducer , getSubId ) => {
124126 return payload => {
127+ const subId = getSubId ( ) ;
125128 const subData = this . store [ subId ] ;
126- subData . over = reducer ( global . over , payload ) ;
129+ console . log ( 'TCL: ChannelStore -> _createAction -> subId' , subId ) ;
130+ console . log ( 'TCL: ChannelStore -> _createAction -> subData' , subData ) ;
131+ const current = {
132+ ...subData . init ,
133+ ...subData . over ,
134+ } ;
135+ const over = ( reducer || this . defaultReducer ) ( current , payload ) ;
136+ subData . over = over ;
137+
127138 this . send ( ) ;
128139 this . subscriber ( ) ;
129140 } ;
130141 } ;
131142
132- createGlobalAction = reducer => this . _createAction ( reducer , GLOBAL ) ;
143+ createGlobalAction = reducer => this . _createAction ( reducer , ( ) => GLOBAL ) ;
133144 createLocalAction = reducer =>
134- this . _createAction ( reducer , this . selectedId || this . id ) ;
145+ this . _createAction ( reducer , ( ) => this . selectorId || this . id ) ;
135146
136147 sendInit = data => {
148+ console . log ( 'TCL: ChannelStore -> onConnectedFn -> id' , this . id ) ;
149+
137150 this . init ( data ) ;
138151 } ;
139152
0 commit comments