[RN] Cleanup subscriptions for the invite module
This commit is contained in:
parent
cf6dd98b02
commit
ed7d8ac57e
|
@ -33,6 +33,9 @@ const { Invite } = NativeModules;
|
||||||
*/
|
*/
|
||||||
Invite && MiddlewareRegistry.register(store => next => action => {
|
Invite && MiddlewareRegistry.register(store => next => action => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
|
case _SET_EMITTER_SUBSCRIPTIONS:
|
||||||
|
return _setEmitterSubscriptions(store, next, action);
|
||||||
|
|
||||||
case APP_WILL_MOUNT:
|
case APP_WILL_MOUNT:
|
||||||
return _appWillMount(store, next, action);
|
return _appWillMount(store, next, action);
|
||||||
|
|
||||||
|
@ -206,3 +209,29 @@ function _onPerformQuery(
|
||||||
translatedResults);
|
translatedResults);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifies the feature invite that the action
|
||||||
|
* {@link _SET_EMITTER_SUBSCRIPTIONS} is being dispatched within a specific
|
||||||
|
* redux {@code store}.
|
||||||
|
*
|
||||||
|
* @param {Store} store - The redux store in which the specified {@code action}
|
||||||
|
* is being dispatched.
|
||||||
|
* @param {Dispatch} next - The redux dispatch function to dispatch the
|
||||||
|
* specified {@code action} to the specified {@code store}.
|
||||||
|
* @param {Action} action - The redux action {@code _SET_EMITTER_SUBSCRIPTIONS}
|
||||||
|
* which is being dispatched in the specified {@code store}.
|
||||||
|
* @private
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
function _setEmitterSubscriptions({ getState }, next, action) {
|
||||||
|
const { emitterSubscriptions } = getState()['features/invite'];
|
||||||
|
|
||||||
|
if (emitterSubscriptions) {
|
||||||
|
for (const subscription of emitterSubscriptions) {
|
||||||
|
subscription.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return next(action);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue