Skip to content
This repository has been archived by the owner on Sep 4, 2019. It is now read-only.

Support offline mode #29

Closed
ekryski opened this issue Feb 16, 2016 · 21 comments
Closed

Support offline mode #29

ekryski opened this issue Feb 16, 2016 · 21 comments
Labels

Comments

@ekryski
Copy link
Member

ekryski commented Feb 16, 2016

It would be really ballin' to detect if the user has an internet connection. If they don't, store actions in a local store and then emit events back to the server when they regain a connection.

You'd probably also need to refresh all your data to make sure you have the same state as the server in the event that other users updated data you care about while you were offline.

@luizbills
Copy link

👍

@HiveTechDev
Copy link

Would love to see this feature as well. :) But from what i've found of feathersjs, i'm excited to say the least.

@katopz
Copy link

katopz commented Mar 17, 2016

Just referrer feathersjs/feathers#264

@hnordt
Copy link

hnordt commented Mar 19, 2016

I think it should not be Feathers concern. It's a behaviour that is very tied to the frontend developer "taste" and app requirements, each app has different conflict resolution needs for example.

For example, if the frontend is using Flux, it's straightforward to support offline apps:

const initialState = {
  users: [],
  pending: []
}

function reducer(state = initialState, action) {
  if (action.type === SAVE_USER_SUCCESS) {
    return {  ...state, users: [...users, action.payload] }
  }
  if (action.type === SAVE_USER_FAILURE) {
    return {  ...state, pending: [...pending, action] }
  }
  return state
}

function saveUser(data) {
  return dispatch => {
    userService.update(data)
      .then(() => dispatch(saveUserSuccess())
      .catch(() => {
        dispatch(saveUserFailure(data)
        dispatch(persistState()) // this will persist the pending state
      })
  }
}

function saveUserSuccess() {
  return {
    type: SAVE_USER_SUCCESS
  }
}

function saveUserFailure(data) {
  return {
    type: SAVE_USER_FAILURE,
    payload: data
  }
}

@ekryski
Copy link
Member Author

ekryski commented Mar 19, 2016

@hnordt like everything else it would be entirely optional but we have some ideas about how we can make this work really well and potentially be an alternative to Flux/Redux/Relay, while still keeping it fairly lightweight.

You are definitely correct though, the developer should be in control of which data is cached and how it is cached because that is going to be application specific.

So, while I do agree that it is a developer's concern, I think there is some stuff that Feathers can do to make it easier.

@hnordt
Copy link

hnordt commented Mar 19, 2016

I liked the first idea. I'll experiment some approaches too and I'll share the results.

@ghost
Copy link

ghost commented May 25, 2016

At Google I/O this year there was a talk about offline apps using service workers. I was impressed by how well this approached worked and think it may be the future of running web apps offline. The talk didn't go into deep detail, but their approach is open source. Definitely worth a watch and might apply to how offline is engineered in Feathers: https://www.youtube.com/watch?v=cmGr0RszHc8

Here's the source code for Google's offline service workers: https://github.com/GoogleChrome/ioweb2016/tree/master/app/scripts/sw-toolbox

@marshallswain
Copy link
Member

Cool. Thanks for sharing @tiyindyfee!

@ecerroni
Copy link

@ekryski Any ETA about this feature?

@simonjblack
Copy link

+1

@alvirtuoso
Copy link

+1
Has anyone looked into or used offlinejs? It claims to detect online connection and caches REST calls then handle them automatically when back online

@safizn
Copy link

safizn commented Feb 23, 2017

I think feathers should be separated into small modules and let the developer choose and pick which they like. Just like the concept of Koa middlewares. And ofcourse have a list for the official repositories, separate from those that are third-party.
Don't make another bulky FRAMEWORK ☠️

@daffl
Copy link
Member

daffl commented Feb 23, 2017

That's exactly what Feathers already does (a list of official and unofficial plugins can be found here). I'm not sure what you are suggesting?

@marshallswain
Copy link
Member

@myuseringithub It most absolutely is a genius idea, though! Great minds think alike. 😉

@marshallswain
Copy link
Member

@myuseringithub I see now that Koa support is your actual goal. We'll help wherever possible if you want to create an adapter for it.

@alainrodriguezz
Copy link

Is this feature still on the table? :)

@eddyystop
Copy link

eddyystop commented Apr 24, 2017

Yes, some work is being done on a related approach. There are peripheral issues which will take time to ruggedize in the wild. There is no time table.

@daffl
Copy link
Member

daffl commented Jun 30, 2017

As @eddyystop is doing a lot of great work in this department I think we can close this. See https://docs.feathersjs.com/guides/offline-first/readme.html and the offline repositories in the organization.

@daffl daffl closed this as completed Jun 30, 2017
@binury
Copy link

binury commented Nov 14, 2017

For those coming to this issue from the documentation there is now offline support.

@ramstein74
Copy link

Please update the docs
https://feathersjs.com/feathers-vs-firebase

@daffl
Copy link
Member

daffl commented Sep 10, 2018

The website is editable by anybody directly (e.g. https://github.com/feathersjs/website/edit/master/content/feathers-vs-firebase.html).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests