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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -