Closed ekryski closed 7 years ago
:+1:
Would love to see this feature as well. :) But from what i've found of feathersjs, i'm excited to say the least.
Just referrer https://github.com/feathersjs/feathers/issues/264
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
}
}
@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.
I liked the first idea. I'll experiment some approaches too and I'll share the results.
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
Cool. Thanks for sharing @tiyindyfee!
@ekryski Any ETA about this feature?
+1
+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
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 ☠️
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?
@myuseringithub It most absolutely is a genius idea, though! Great minds think alike. 😉
@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.
Is this feature still on the table? :)
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.
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.
For those coming to this issue from the documentation there is now offline support.
Please update the docs https://feathersjs.com/feathers-vs-firebase
The website is editable by anybody directly (e.g. https://github.com/feathersjs/website/edit/master/content/feathers-vs-firebase.html).
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.