2017-03-01 3 views
0

redux-saga를 사용하여 ReactNative 앱을 만들고 있지만 redux-saga와 함께 일부 플러그인을 사용하는 데 문제가 있습니다.classicx 콜백 함수에서 redux-saga generator를 실행하십시오.

내 코드는 다음과 같습니다. IdsAvailable 생성기를 어떻게 실행할 수 있습니까 ??

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); 

}) 

답변

0

나는 무엇이든지 REDUX - 모험과 경험이 없다하지만 난 당신이 뭔가를 달성하려고하는 것 같아요?

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(); 

}) 
관련 문제