react native - Calling redux actions without bindActionCreator -


i want store gps position of user in redux-store. coords use this:

navigator.geolocation.watchposition( (data) => {   // }, null, {     timeout: 60000,     distancefilter: 10 }); 

i have reducer position:

import createreducer '../lib/createreducer' import * types '../actions/types'  export const position = createreducer({}, {   [types.set_position](state, action) {     return {         latitude: action.latitude,         longitude: action.longitude     };;   } }) 

and action:

import * types './types'  export function watchposition() {   return (dispatch, getstate) => {          ???   } }  export function setposition({ latitude, longitude }) {   console.log('ja');   return {     type: types.set_position,     latitude,     longitude   } } 

i want init watchposition in home-screen. don't bind actions there (no connect() ).

how call action , init reducer when new position available?

you czn import store object in commponent or executive place of code , use store.dispatch(() => { return{ type: action_type, payload: data } }).

or can use reduxthunk middleware touch store: store.dispatch({ type: action_type, payload: data }).

hope you


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -