All Projects → itinance → redux-saga-location

itinance / redux-saga-location

Licence: MIT License
Geo-Location-support for redux-saga

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to redux-saga-location

twitter-spring-reactjs
🐦 Twitter Clone. Using Java, Spring Boot, PostgreSQL, S3 bucket, JWT, TypeScript, React.js, Redux-Saga, Material-UI
Stars: ✭ 47 (+135%)
Mutual labels:  redux-saga
redux-saga-in-korean
redux-saga 공식문서의 한국어 번역 프로젝트.
Stars: ✭ 73 (+265%)
Mutual labels:  redux-saga
react-easy-ssr
🔥 React Starter Project with Webpack 5, Babel 7, TypeScript, Redux-saga, Styled-components, React-jss, Split code, Server Side Rendering.
Stars: ✭ 31 (+55%)
Mutual labels:  redux-saga
react-login-registration
An example React / Redux / Redux Saga application talking to a Symfony 3 API
Stars: ✭ 31 (+55%)
Mutual labels:  redux-saga
molecule
⚛️ –  – ⚛️ Boilerplate for cross platform web/native react apps with electron.
Stars: ✭ 95 (+375%)
Mutual labels:  redux-saga
coconat
🍥 StarterKit Builder for rocket-speed App creation on 🚀 React 17 + 📙 Redux 4 + 🚠 Router 5 + 📪 Webpack 5 + 🎳 Babel 7 + 📜 TypeScript 4 + 🚔 Linters 23 + 🔥 HMR 3
Stars: ✭ 95 (+375%)
Mutual labels:  redux-saga
react-native-boilerplate
从真实项目中抽离出的一个简单的样板。(A simple boilerplate stripping out of a real project.)
Stars: ✭ 21 (+5%)
Mutual labels:  redux-saga
BulletJournal
An organizational system that helps you keep track of everything in your busy life
Stars: ✭ 117 (+485%)
Mutual labels:  redux-saga
rc-redux-model
一种较为舒适的数据状态管理书写方式,内部自动生成 action, 只需记住一个 action,可以修改任意的 state 值,方便简洁,释放你的 CV 键~
Stars: ✭ 48 (+140%)
Mutual labels:  redux-saga
saga-monitor
Simple, elegant, and configurable redux-saga monitor
Stars: ✭ 37 (+85%)
Mutual labels:  redux-saga
react-rocketshoes
NetShoes Clone with React and Redux
Stars: ✭ 50 (+150%)
Mutual labels:  redux-saga
enlite-starter
Enlite Starter - React Dashboard Starter Template with Firebase Auth
Stars: ✭ 28 (+40%)
Mutual labels:  redux-saga
gostack-rocketshoes-react
👞 Sample store built with Redux and Redux-Saga
Stars: ✭ 35 (+75%)
Mutual labels:  redux-saga
generator-react-web
Yeoman generator for creating interactive web sites with React and Redux + Webpack, Flow, ES7+, Babel, Yarn, npm Scripts, i18n, Redux Saga, SCSS, CSS Modules
Stars: ✭ 35 (+75%)
Mutual labels:  redux-saga
next-redux-saga-boilerplate
Next/Redux/Saga boilerplate - Example of using Next.js 9 with Redux Saga
Stars: ✭ 13 (-35%)
Mutual labels:  redux-saga
mickey
🤠 Lightweight front-end framework for creating React and Redux based app painlessly.
Stars: ✭ 26 (+30%)
Mutual labels:  redux-saga
isomorphic-react-redux-saga-ssr
Isomorphic, React, Redux, Saga, Server Side rendering, Hot Module Reloading, Ducks, Code Splitting
Stars: ✭ 19 (-5%)
Mutual labels:  redux-saga
use-saga-reducer
Use redux-saga without redux
Stars: ✭ 72 (+260%)
Mutual labels:  redux-saga
ReactNativeStarterKits
Agiletech React Native Starter Kits
Stars: ✭ 21 (+5%)
Mutual labels:  redux-saga
admin-template-for-react
🌏 Admin template for React, React Redux, Redux Saga, React Router, i18n and integrated OAuth login
Stars: ✭ 83 (+315%)
Mutual labels:  redux-saga

redux-saga-location

GeoLocation within 'redux-saga'-context.

This library helps along to fetch geo-location within a saga (or any other generator function) and put the result into the redux-store.

Installation

yarn add redux-saga-location @react-native-community/geolocation

or

npm install redux-saga-location @react-native-community/geolocation --save

Setup

In the root reducer add the location-reducer. For instance:

reducer.js:

import { locationReducer as location } from "redux-saga-location";

const appReducer = combineReducers({
  appStates,
  routes,
  ...location
});

In the root saga spawn the channel watcher:

saga.js

import {
  watchLocationChannel,
  getCurrentPosition,
  watchCurrentPosition
} from "redux-saga-location";

export default function* rootSaga() {
  yield [
    // ... all your sagas here
    spawn(watchLocationChannel)
  ];
}

Usage

Usage of getCurrentPosition

We call getCurrentPosition according to the web-standard-method and (if user permits) the current position will be put into the redux store.

yield call(getCurrentPosition)

The received data is the same as from navigator.geolocation.getCurrentPosition. Starting with react-native 0.60 navigator.geolocation has been removed and moved to Geolocation.getCurrentPosition

Usage of watchCurrentPosition

We call watchCurrentPosition according to the web-standard-method and (if user permits) the position will be put into the redux store as often as it gets updated.

yield call(watchCurrentPosition)

The received data is the same as from navigator.geolocation.watchPosition. Starting with react-native 0.60 navigator.geolocation has been removed and moved to Geolocation.watchPosition

We can listen to the event in our reducers per "REDUX_SAGA_LOCATION_SET_POSITION", while errors can be detected with "REDUX_SAGA_LOCATION_SET_ERROR".

If we want to use constants for the actions, we can import them with:

import {
  REDUX_SAGA_LOCATION_ACTION_SET_POSITION,
  REDUX_SAGA_LOCATION_ACTION_SET_ERROR
} from "redux-saga-location/actions";

We'll find the result in our redux-store like this:

alt text

Contribution:

Contributors are welcome! Feel free to submit pull requests or open discussions.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].