feathersjs-ecosystem / client

[MOVED] Client side Feathers build
https://github.com/feathersjs/feathers
MIT License
111 stars 27 forks source link

Support offline mode #29

Closed ekryski closed 7 years ago

ekryski commented 8 years ago

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 commented 8 years ago

:+1:

HiveTechDev commented 8 years ago

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

katopz commented 8 years ago

Just referrer https://github.com/feathersjs/feathers/issues/264

hnordt commented 8 years ago

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 commented 8 years ago

@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 commented 8 years ago

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

ghost commented 8 years ago

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 commented 8 years ago

Cool. Thanks for sharing @tiyindyfee!

ecerroni commented 8 years ago

@ekryski Any ETA about this feature?

simonjblack commented 8 years ago

+1

alvirtuoso commented 8 years ago

+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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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

marshallswain commented 7 years ago

@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 commented 7 years ago

Is this feature still on the table? :)

eddyystop commented 7 years ago

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 commented 7 years ago

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.

binury commented 6 years ago

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

ramstein74 commented 6 years ago

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

daffl commented 6 years ago

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