redux-effects-geolocation

1.0.2 • Public • Published

redux-effects-geolocation

redux-effects middleware for Geolocation API.

Installation

npm install --save redux-effects-geolocation

Usage

Installing the middleware

import { createStore, applyMiddleware } from 'redux';
import geoMiddleware from 'redux-effects-geolocation';
import rootReducer from './reducers';

const store = createStore(
  rootReducer,
  applyMiddleware(
    geoMiddleware()
  )
);

Using Actions:

getting current position:

import { getPosition } from 'redux-effects-geolocation';

const propmise = store.dispatch(getPosition());

getting current position with options:

import { getPosition } from 'redux-effects-geolocation';

const propmise = store.dispatch(getPosition({ enableHighAccuracy: true }));

Note: If Geolocation API is not available, the Promise is always rejected.

API

Action Creators

getPosition([options])

Arguments
  • options (Object): See MDN for more info.
Returns
  • (Object): An action object.

Package Sidebar

Install

npm i redux-effects-geolocation

Weekly Downloads

167

Version

1.0.2

License

MIT

Last publish

Collaborators

  • koichik
  • yosuke-furukawa