4

I'm using Redux saga and OneSignal in my React Native app. In my saga I have the following generator function:

function* getOneSignalIDs() {
    try {
        OneSignal.init(appID)
        OneSignal.addEventListener('ids', (device) => {
            yield put(OneSignalActionCreators.getOneSignalIDsSuccess(device.pushToken, device.userId));
        });
    } catch(error) {}
}

The problem with this code is that yield put has to be inside a generator function, but my event listener isn't a generator.

Does anyone know how I can approach this?

gkeenley
  • 6,088
  • 8
  • 54
  • 129
  • 1
    Does this answer your question? [How to tie emitted events events into redux-saga?](https://stackoverflow.com/questions/35277682/how-to-tie-emitted-events-events-into-redux-saga) – ArchNoob May 03 '20 at 00:24
  • Did you solve this problem? – Shawn Sep 13 '20 at 13:11
  • 1
    Thanks @ArchNoob this answer https://stackoverflow.com/a/38762340/3385744 from the post solve my issue – gigeos Apr 21 '22 at 13:48

0 Answers0