redux-effects middleware for Geolocation API.
npm install --save redux-effects-geolocation
import { createStore, applyMiddleware } from 'redux';
import geoMiddleware from 'redux-effects-geolocation';
import rootReducer from './reducers';
const store = createStore(
rootReducer,
applyMiddleware(
geoMiddleware()
)
);
getting current position:
import { getPosition } from 'redux-effects-geolocation';
const promise = store.dispatch(getPosition());
getting current position with options:
import { getPosition } from 'redux-effects-geolocation';
const promise = store.dispatch(getPosition({ enableHighAccuracy: true }));
Note: If Geolocation API is not available, the Promise is always rejected.
options
(Object): See MDN for more info.
- (Object): An action object.