2017-03-01 57 views
0

我使用REDX-SAGA创建了一个ReactNative应用程序,但是我有一些问题需要使用一些插件与REDX-SAY结合使用。从经典的回调函数执行发生器的REDX-SAGA

我的代码看起来像那样。 如何执行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

我有终极版,传奇没有任何经验,但我猜你正在努力实现这样的事情?

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

})