All Projects → redux-offline → Redux Offline

redux-offline / Redux Offline

Licence: mit
Build Offline-First Apps for Web and React Native

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Redux Offline

Shaka Player
JavaScript player library / DASH & HLS client / MSE-EME player
Stars: ✭ 5,386 (-11.21%)
Mutual labels:  offline-capable
ambianic-ui
PWA for managing Ambianic Edge devices (smart cameras).
Stars: ✭ 32 (-99.47%)
Mutual labels:  offline-capable
nativescript-task-app
An example task management NativeScript Angular app. Demonstrates ngrx effects, lazy-loading modules, offline storage and app branding.
Stars: ✭ 26 (-99.57%)
Mutual labels:  offline-capable
DroidShows
A Reboot of DroidSeries Offline TV Shows Tracker
Stars: ✭ 69 (-98.86%)
Mutual labels:  offline-capable
preserver-plus
Minimal notes app
Stars: ✭ 34 (-99.44%)
Mutual labels:  offline-capable
docker-nginx-certbot
Automatically create and renew website certificates for free using the Let's Encrypt certificate authority.
Stars: ✭ 367 (-93.95%)
Mutual labels:  offline-capable
progressive
This is the repository for my course, Building a Progressive Web App on LinkedIn Learning and Lynda.com.
Stars: ✭ 26 (-99.57%)
Mutual labels:  offline-capable
np8080
A web based text editor written with AngularDart.
Stars: ✭ 17 (-99.72%)
Mutual labels:  offline-capable
sigmah
Open source software for managing international aid projects
Stars: ✭ 22 (-99.64%)
Mutual labels:  offline-capable
Mono-PWA
Monobank PWA — unofficial online web client for monobank
Stars: ✭ 24 (-99.6%)
Mutual labels:  offline-capable
the-shrine-ng
🔴 A progressive web app of a retro soundboard. The Shrine comes with "Gude Laune!" and many more legendary sounds. 🔊
Stars: ✭ 16 (-99.74%)
Mutual labels:  offline-capable
affilicats
🐈 Progressive Web App demo that showcases flaky network resilience measures (📶 or 🚫📶).
Stars: ✭ 65 (-98.93%)
Mutual labels:  offline-capable
Dianoia-app
Mobile (Ionic 3 - Angular 4) app about non-pharmaceutical activities and information for people with dementia.
Stars: ✭ 13 (-99.79%)
Mutual labels:  offline-capable
Remotestorage.js
⬡ JavaScript client library for integrating remoteStorage in apps
Stars: ✭ 2,155 (-64.47%)
Mutual labels:  offline-capable
Imageai
A python library built to empower developers to build applications and systems with self-contained Computer Vision capabilities
Stars: ✭ 6,734 (+11.01%)
Mutual labels:  offline-capable

redux-offline

npm version travis

🚨🚨🚨🚨 v3 is coming soon! Check the progress updates HERE


Persistent Redux store for Reasonaboutable™️ Offline-First applications, with first-class support for optimistic UI. Use with React, React Native, or as standalone state container for any web app.

Redux Offline is now being maintained by a community driven team. The new versions of the library will now be available under the npm organization @redux-offline. Big thank you to @jevakallio for creating this amazing library in the first place.

Quick start

1. Install with npm (or Yarn)
For React Native 0.60+
npm install --save @redux-offline/redux-offline@native

For React Native Expo SDK 36

npm install --save @redux-offline/redux-offline@expo

For React Native <= 0.59

npm install --save @redux-offline/redux-offline
2. Add the offline store enhancer with compose
import { applyMiddleware, createStore, compose } from 'redux';
import { offline } from '@redux-offline/redux-offline';
import offlineConfig from '@redux-offline/redux-offline/lib/defaults';

// ...

const store = createStore(
  reducer,
  preloadedState,
  compose(
    applyMiddleware(middleware),
    offline(offlineConfig)
  )
);
3. Decorate actions with offline metadata
const followUser = userId => ({
  type: 'FOLLOW_USER_REQUEST',
  payload: { userId },
  meta: {
    offline: {
      // the network action to execute:
      effect: { url: '/api/follow', method: 'POST', json: { userId } },
      // action to dispatch when effect succeeds:
      commit: { type: 'FOLLOW_USER_COMMIT', meta: { userId } },
      // action to dispatch if network action fails permanently:
      rollback: { type: 'FOLLOW_USER_ROLLBACK', meta: { userId } }
    }
  }
});

If the effect payload is something other than JSON you can pass the body and headers:

const registerUser = (name, email) => ({
  type: 'REGISTER_USER',
  payload: { name, email },
  meta: {
    offline: {
      // the network action to execute:
      effect: { url: '/api/register', method: 'POST', body: `name=${name}&email=${email}`, headers: { 'content-type': 'application/x-www-form-urlencoded' } },
      // action to dispatch when effect succeeds:
      commit: { type: 'REGISTER_USER_COMMIT', meta: { name, email } },
      // action to dispatch if network action fails permanently:
      rollback: { type: 'REGISTER_USER_ROLLBACK', meta: { name, email } }
    }
  }
});
4. (React Native Android) Ask permission to read network status

If writing a native app for Android, you'll need to make sure to request the permission to access network state in your AndroidManifest.xml:

  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

See Documentation for configuration options, the full API, and common recipes.

Contributing

Improvements and additions welcome. For large changes, please submit a discussion issue before jumping to coding; we'd hate you to waste the effort.

If you are reporting a bug, please include code that reproduces the error. Here is a starting application on CodeSandbox.

In lieu of a formal style guide, follow the included eslint rules, and use Prettier to format your code.

Miscellanea

Usage with Redux Persist v5

In case you want to use a custom redux-persist version, there is an example configuration.

Prior art

Redux Offline is a distillation of patterns discovered while building apps using previously existing libraries:

Without their work, Redux Offline wouldn't exist. If you like the ideas behind Redux Offline, but want to build your own stack from lower-level components, these are good places to start.

License

MIT

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].