Created
February 16, 2020 22:01
-
-
Save AllGistsEqual/7702ca38b412417950d7da493312d6fa 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
import { USER_LOGIN } from '../../actions/user.actions' | |
import * as RootNavigation from '../../../navigation/RootNavigation' | |
const fakeLoginCheck = () => true // It's an older code, sir, but it checks out. | |
const userMiddleware = () => (next) => (action) => { | |
if (action.type === USER_LOGIN) { | |
if (fakeLoginCheck()) { | |
next(action) // continue with the login | |
setTimeout(() => { // wait a moment before triggering the navigation | |
RootNavigation.navigate('Home') | |
}, 2000) | |
} | |
} | |
} | |
export default userMiddleware |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment