Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event channel stops working after react native reload #517

Open
luskin opened this issue Nov 7, 2019 · 0 comments
Open

Event channel stops working after react native reload #517

luskin opened this issue Nov 7, 2019 · 0 comments

Comments

@luskin
Copy link

luskin commented Nov 7, 2019

The following code block works just fine every time you reload the app:

function * syncAuth () {
  const channel = yield call(rsf.auth.channel)

  while (true) {
    const { user } = yield take(channel)
    console.log('User received: ', user)
  }
}

export default function * rootSagas () {
  yield fork(syncUserSaga)
}

HOWEVER if you want to delay the start of this process you cannot fork this from any other saga after any reload. It WILL work the very first time the app is launched but all subsequent reloads break:

function * initialize () {
  // ... a bunch of other app initialization stuff...
 fork(syncAuth)
  // ... more etc
}

function * syncAuth () {
  console.log(1)
  const channel = yield call(rsf.auth.channel)
  while (true) {
    console.log(2)
    const { user } = yield take(channel)
    console.log('User received: ', user)
  }
}

export default function * rootSagas () {
  yield fork(initialize)
}

The output of this is:

1
2

but the User received is never resolved.

@luskin luskin changed the title Event channel stops working on react native reload Event channel stops working after react native reload Nov 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant