【发布时间】:2019-08-01 20:55:41
【问题描述】:
我想在 TaskManager.defineTask 回调中使用 yield 并使用 yield 调度 redux 存储,但我做不到
我什么都试过了
import { all, put, call } from 'redux-saga/effects'
import * as TaskManager from 'expo-task-manager';
import * as Location from 'expo-location';
import * as Permissions from 'expo-permissions';
function* dispatchLocation(locations){
console.log("Entro d")
yield put({ type: 'permission/SET_LOCATION', data: locations })
}
TaskManager.defineTask('LocationWatcher', ({ data: { locations }, error }) => {
if (error) {
// check `error.message` for more details.
return;
}
console.log('enn')
yield dispatchLocation(locations)
});
function* watchLocation(){
let { status } = yield Permissions.getAsync(Permissions.LOCATION);
console.log(status)
if (status === 'granted') {
Location.startLocationUpdatesAsync('LocationWatcher',{})
}
}
export default function* rootSaga() {
//call(watchLocation())
yield all([
watchLocation()
])
}
【问题讨论】:
标签: javascript react-redux redux-saga