React native 在没有bindActionCreator的情况下调用redux操作

React native 在没有bindActionCreator的情况下调用redux操作,react-native,redux,react-redux,React Native,Redux,React Redux,我想在我的redux存储中存储用户的GPS位置。要获得坐标,我使用以下方法: navigator.geolocation.watchPosition( (data) => { // }, null, { timeout: 60000, distanceFilter: 10 }); 我有一个适合这个职位的减速机: import createReducer from '../lib/createReducer' import * as types from '../act

我想在我的redux存储中存储用户的GPS位置。要获得坐标,我使用以下方法:

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
  }
}
我想在我的主屏幕上初始化这个watchPosition。我不把行动绑在一起,没有联系


当新位置可用时,如何调用此操作并初始化减速机?

您可以在组件或其他代码执行位置导入存储对象,然后使用store.dispatch=>{return{type:action\u type,payload:data}}

或者您可以使用中间件来接触store:store.dispatch{type:ACTION\u type,payload:data}

希望这对你有帮助