Skip to content

Instantly share code, notes, and snippets.

@AllGistsEqual
Created February 16, 2020 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AllGistsEqual/7702ca38b412417950d7da493312d6fa to your computer and use it in GitHub Desktop.
Save AllGistsEqual/7702ca38b412417950d7da493312d6fa to your computer and use it in GitHub Desktop.
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