0
我想將用戶的GPS位置存儲在我的redux-store中。爲了讓我用這個座標:調用redux動作,無bindActionCreator
navigator.geolocation.watchPosition((data) => {
//
}, null, {
timeout: 60000,
distanceFilter: 10
});
我對位置的減速機:
import createReducer from '../lib/createReducer'
import * as types from '../actions/types'
export const position = createReducer({}, {
[types.SET_POSITION](state, action) {
return {
latitude: action.latitude,
longitude: action.longitude
};;
}
})
和動作:
import * as types from './types'
export function watchPosition() {
return (dispatch, getState) => {
???
}
}
export function setPosition({ latitude, longitude }) {
console.log('JA');
return {
type: types.SET_POSITION,
latitude,
longitude
}
}
我想在我家Init這watchPosition -屏幕。我不綁定那裏的動作(沒有連接())。
如何調用此操作並在新位置可用時初始化縮減器?