浏览代码

[RN] Cleanup subscriptions for the invite module

master
Saúl Ibarra Corretgé 7 年前
父节点
当前提交
ed7d8ac57e
共有 1 个文件被更改,包括 29 次插入0 次删除
  1. 29
    0
      react/features/invite/middleware.native.js

+ 29
- 0
react/features/invite/middleware.native.js 查看文件

@@ -33,6 +33,9 @@ const { Invite } = NativeModules;
33 33
  */
34 34
 Invite && MiddlewareRegistry.register(store => next => action => {
35 35
     switch (action.type) {
36
+    case _SET_EMITTER_SUBSCRIPTIONS:
37
+        return _setEmitterSubscriptions(store, next, action);
38
+
36 39
     case APP_WILL_MOUNT:
37 40
         return _appWillMount(store, next, action);
38 41
 
@@ -206,3 +209,29 @@ function _onPerformQuery(
206 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
+}

正在加载...
取消
保存