Last active
June 5, 2017 06:19
-
-
Save erezrokah/b8c4ac6e888c3c62835afe4b460817ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//@flow | |
export function listenRemoved(metaType: string) { | |
return { | |
type: 'FIREBASE_LISTEN_REMOVED', | |
metaType, | |
} | |
} | |
export function removeListenerRef(state: Object, metaType: string) { | |
if (state && state.database && state.database[metaType] && | |
state.database[metaType].ref) { | |
return state.database[metaType].ref.off() | |
} | |
return Promise.resolve() | |
} | |
type Action = { | |
type: string, | |
metaType: string, | |
} | |
export function removeListener(metaType: string) { | |
return (dispatch: Action => void, getState: () => Object) => { | |
return removeListenerRef(getState(), metaType).then(() => { | |
dispatch(listenRemoved(metaType)) | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment