Pārlūkot izejas kodu

[RN] Cleanup subscriptions for the invite module

j8
Saúl Ibarra Corretgé 7 gadus atpakaļ
vecāks
revīzija
ed7d8ac57e
1 mainītis faili ar 29 papildinājumiem un 0 dzēšanām
  1. 29
    0
      react/features/invite/middleware.native.js

+ 29
- 0
react/features/invite/middleware.native.js Parādīt failu

33
  */
33
  */
34
 Invite && MiddlewareRegistry.register(store => next => action => {
34
 Invite && MiddlewareRegistry.register(store => next => action => {
35
     switch (action.type) {
35
     switch (action.type) {
36
+    case _SET_EMITTER_SUBSCRIPTIONS:
37
+        return _setEmitterSubscriptions(store, next, action);
38
+
36
     case APP_WILL_MOUNT:
39
     case APP_WILL_MOUNT:
37
         return _appWillMount(store, next, action);
40
         return _appWillMount(store, next, action);
38
 
41
 
206
                 translatedResults);
209
                 translatedResults);
207
         });
210
         });
208
 }
211
 }
212
+
213
+/**
214
+ * Notifies the feature invite that the action
215
+ * {@link _SET_EMITTER_SUBSCRIPTIONS} is being dispatched within a specific
216
+ * redux {@code store}.
217
+ *
218
+ * @param {Store} store - The redux store in which the specified {@code action}
219
+ * is being dispatched.
220
+ * @param {Dispatch} next - The redux dispatch function to dispatch the
221
+ * specified {@code action} to the specified {@code store}.
222
+ * @param {Action} action - The redux action {@code _SET_EMITTER_SUBSCRIPTIONS}
223
+ * which is being dispatched in the specified {@code store}.
224
+ * @private
225
+ * @returns {*}
226
+ */
227
+function _setEmitterSubscriptions({ getState }, next, action) {
228
+    const { emitterSubscriptions } = getState()['features/invite'];
229
+
230
+    if (emitterSubscriptions) {
231
+        for (const subscription of emitterSubscriptions) {
232
+            subscription.remove();
233
+        }
234
+    }
235
+
236
+    return next(action);
237
+}

Notiek ielāde…
Atcelt
Saglabāt