0

I'm creating a ReactNative app using redux-saga, but I have some problem to use some of the plugins in combination with redux-saga.

My code looks like that. How can I execute the IdsAvailable generator??

function *IdsAvailable(pushToken, userId){
   yield put({ type: 'PUSH_TOKEN_AVAILABLE', pushToken })
}

OneSignal.addEventListener('ids', function * ({ pushToken, userId }){
    // this of course dosn't work
    IdsAvailable(pushToken, userId);

})

1 Answers1

0

I have no experience with redux-saga whatsoever but I guess you are trying to achieve something like this?

function *IdsAvailable(pushToken, userId){
   yield put({ type: 'PUSH_TOKEN_AVAILABLE', pushToken })
}

OneSignal.addEventListener('ids', function * ({ pushToken, userId }){
    // just call next() and the generator will yield the next value
    // (in this case call the put method)
    IdsAvailable(pushToken, userId).next();

})
Patrik Prevuznak
  • 2,181
  • 15
  • 14