44 ArrayPrototypeAt,
55 ArrayPrototypeIndexOf,
66 ArrayPrototypePush,
7+ ArrayPrototypePushApply,
8+ ArrayPrototypeSlice,
79 ArrayPrototypeSplice,
810 ObjectDefineProperty,
911 ObjectGetPrototypeOf,
@@ -97,6 +99,7 @@ function wrapStoreRun(store, data, next, transform = defaultTransform) {
9799class ActiveChannel {
98100subscribe ( subscription ) {
99101validateFunction ( subscription , 'subscription' ) ;
102+ this . _subscribers = ArrayPrototypeSlice ( this . _subscribers ) ;
100103ArrayPrototypePush ( this . _subscribers , subscription ) ;
101104channels . incRef ( this . name ) ;
102105}
@@ -105,7 +108,10 @@ class ActiveChannel {
105108const index = ArrayPrototypeIndexOf ( this . _subscribers , subscription ) ;
106109if ( index === - 1 ) return false ;
107110
108- ArrayPrototypeSplice ( this . _subscribers , index , 1 ) ;
111+ const before = ArrayPrototypeSlice ( this . _subscribers , 0 , index ) ;
112+ const after = ArrayPrototypeSlice ( this . _subscribers , index + 1 ) ;
113+ this . _subscribers = before ;
114+ ArrayPrototypePushApply ( this . _subscribers , after ) ;
109115
110116channels . decRef ( this . name ) ;
111117maybeMarkInactive ( this ) ;
@@ -137,9 +143,10 @@ class ActiveChannel {
137143}
138144
139145publish ( data ) {
140- for ( let i = 0 ; i < ( this . _subscribers ?. length || 0 ) ; i ++ ) {
146+ const subscribers = this . _subscribers ;
147+ for ( let i = 0 ; i < ( subscribers ?. length || 0 ) ; i ++ ) {
141148try {
142- const onMessage = this . _subscribers [ i ] ;
149+ const onMessage = subscribers [ i ] ;
143150onMessage ( data , this . name ) ;
144151} catch ( err ) {
145152process . nextTick ( ( ) => {
0 commit comments