I need to do a global addEventListener
like thing. I am using react native and need to listen for deep link redirect events. I couldn't figure out the redux-saga way to do this. I need to enable a put
from the callback within the addEventListener.
I currently do the bad hack of importing store
then doing store.dispatch(...)
as seen here:
import store from './flow-control'
Linking.addEventListener('url', ({ url }) => store.dispatch(_redir(url)));
Is there a redux-saga way to do this?
I was hoping to put this into a a saga maybe:
function* reduxSaga() {
const url = yield Linking.addEventListener('url', ({ url }) => ???);
}
Or at the least replace store.dispatch with put like this:
import { put } from 'redux-saga/effects'
Linking.addEventListener('url', ({ url }) => put(_redir(url)));
Whats the right way to do this with redux-saga?
eventChannel
for this? It says here redux-saga.js.org/docs/advanced/Channels.html for "external events". It sounds like its my case but im not sure. I'm new to channels. Thanks Alex! – Unset