sorodrigo / redux-offline Goto Github PK
View Code? Open in Web Editor NEWThis project forked from redux-offline/redux-offline
Build Offline-First Apps for Web and React Native
License: MIT License
This project forked from redux-offline/redux-offline
Build Offline-First Apps for Web and React Native
License: MIT License
redux-offline/issues/77 is still a problem.
You could expose the offline middleware so the user could apply it wherever. This way the logger and offline middleware could be part of the same middleware chain, which means logger could then see the actions offline was dispatching.
const loggerMiddleware = createLogger();
const { middleware: offlineMiddleware, enhancer: offlineEnhancer } = offline(config);
const store = createStore(reducer, initialState, compose(
applyMiddleware(offlineMiddleware, loggerMiddleware),
offlineEnhancer
));
Pretty sure that would work, but it would mean a change in the api.
Otherwise you could advise the user that they may need to apply the offline enhancer earlier than they might be used to. So you could end up with something like the following, which looks a bit weird.
const store = createStore(reducer, initialState, compose(
applyMiddleware(thunk),
offline(config),
applyMiddleware(logger)
));
Pretty much following up on this issue redux-offline#72 in this repo since it is actively maintained.
What do you think? That seeems like a reasonable idea, as you don't necessarily want to dispatch a commit/rollback action for every offline action, for example in the case of an optimistic update (as shown in examples in the README).
I wonder if that lib could be extended by delayed send functionality which would basically allow "undo" action like GMail does. In Gmail when you send an email it is shown to the user as sent, but its not actually send to the server for another 5 seconds. If the users decides to "undo" the send the request to the server is never sent.
Maybe this could be coded as an extension (another middleware) to this lib? I just can not really wrap my head around how the "undo" would be able to work. I think the action would have to contain more info in the metadata for the rollback so that the optimistic UI update can also be reverted properly.
Would someone with owner access to the repo mind heading over to https://travis-ci.org/ and enabling the builds so we can have PR checks? (not sure who that would be at this point).
Thanks for maintaining this project!
The doc says:
The function is passed a callback, which you should call with boolean true when the app gets back online, and false when it goes offline.
https://github.com/redux-offline/redux-offline#change-how-network-status-is-detected
The code expects an object { online: true / false }
https://github.com/redux-offline/redux-offline/blob/develop/src/defaults/detectNetwork.js#L8
Offline/STATUS_CHANGED
is trigger with an empty payload object.I can provide a fix, I guess that'd be a breaking change, let me know if that's fine.
After upgrade to newer 2.2.0 version we are getting a Uncaught ReferenceError: regeneratorRuntime is not defined
error after data is fetch from out server, while with 2.1.0 it correctly works. Seems like it's not able to correctly upgrade the UI. This happens both with React 15 and 16.
Lets discuss the migration strategy.
Probably want to wait for the repos to be merged before going ahead with this, but as we are adding features a changelog would be useful I think.
hello,
with this fork is it possible to dispatch action after commit event fired? like we do with redux-thunk
thanks
hi friends. i've just gotten into using redux-localstorage and redux-persist.
redux-offline has peaked my interest but i have a question to see if it could solve this problem.
if i dispatch an async api action... optimistically update my state before the api returns and refresh the page before the api responds, will redux-offline, when the page is refreshed have context on this request not being fulfilled? will it retry? will it rollback?
right now i have a problem in which my remote and local state get out of sync and then refreshing the page, my local stage gets overriden by remote state and my page flashes.
Hello!
Thanks a lot for maintianing the library.
I was wondering how do I dispatch multiple actions like we do in redux-thunk? I can currently see that we can only have one API call.
I've got this error with react-native app and HMR:
Unexpected key "offline" found in preloadedState argument passed to createStore. Expected to find one of the known reducer keys instead: "user". Unexpected keys will be ignored.
my configureStore.js
/* global __DEV__ */
import { applyMiddleware, createStore, compose } from 'redux';
import { offline } from '@redux-offline/redux-offline';
import offlineConfig from '@redux-offline/redux-offline/lib/defaults';
const createStoreWithMiddleware = compose(
applyMiddleware(
...middlewares,
),
offline({
...offlineConfig,
persistOptions: {
whitelist: ['user'],
},
}),
)(createStore);
const store = createStoreWithMiddleware(reducers);
if (module.hot) {
module.hot.accept(() => {
const nextRootReducer = require('../modules/index').default; // eslint-disable-line
store.replaceReducer(nextRootReducer);
});
}
export default store;
something wrong with my code or is there bug in redux-offline
Hi @sorodrigo,
thanks a lot for opening and maintaining this repository.
A couple of months ago I opened this PR: redux-offline#99
to allow the use of immutable root state
with redux-offline
.
Since then we have been successfully using the fork with our immutable root state.
I wanted to check with you whether the same PR could be merged in this fork if I create it and rebase it in top of the current improvements.
Thanks
Probably a contentious suggestion, but I've found the tooling around typescript to be a little easier to maintain. I'd be happy to create a PR mapping the existing types / setup to typescript as well.
Also totally understand if many people feel that is too far of a leap.
The default effector sends data as JSON, but it's needed to use JSON.stringify()
yourself. It would makes sense to do it automatically, so users only needs to give and receive objects.
Could we please expose constants so we could react on REHYDRATE actions?
I'd like to use this community maintained package of redux-offline with https://github.com/Malpaux/apollo-offline. Apollo-offline correctly requires a redux-offline greater than major version of 2, since jevakallio introduced a breaking API change with that release in April.
This fork does appear to include that new API (offline
rather than createOfflineStore
), but still carries a package version of 1.1.0.
I've created PR #18 for this minor metadata change.
Currently, the code cannot be searched because searching code in a forked repo is not possible on Github. Would you consider 'disconnecting' the fork, so this becomes a stand-alone repo?
I want to use redux-offline
to implement a manual sync feature in my app. I thought about overriding config.detectNetwork
and manually return true to trigger the updating.
The only issue I'm facing is that I want to detect when the app is busy syncing. Any pointers on how to implement that part? Ideally I'm looking for a way to detect that the sync is complete.
I would like to retrieve an API access token, that is stored inside redux state, before making any API calls. Thus, I would need to access the state when I issue a remote fetch
aka effect.
BTW is it a good idea to store credentials (access token) within the persisted redux state?
There has been some conversations about including prettier, just a reminder to do it someday.
In the original repo, there are a few PRs to toggle or customize logging, but I see no reason to keep it around at all. Almost anything interesting that happens in the library is accompanied by an action anyways.
I've found that 4xx errors are not discarding requests with the default configs, going against what the docs says. I think this was working correctly on the @jevakallio code...
How can I be able to override the requests queue? I would allow to the user to do logout and some time later login again, but if there has been some conectivity errors in the past and the requests queue is not empty, then login will be delayed until all previous requests have been commited instead of allowing to do login and keep doing them in background. Is it possible to override the requests queue abd do this someway?
Is it possible to use Redux-Offline with the forked version of React-Boilerplate with Immutablejs removed: https://github.com/Dattaya/react-boilerplate-object ? I'm attempting to implement the offline enhancer by adding it to the enhancers array in app/store.js like this:
const enhancers = [ applyMiddleware(...middlewares), offline(offlineConfig), ];
but I get this error:
Cannot read property 'outbox' of undefined
After investigation it appears this has something to do with redux-devtools-extension. If I remove all reference to devtools and just use standard redux compose it throws this error:
Unexpected key "offline" found in preloadedState argument passed to createStore. Expected to find one of the known reducer keys instead: "routing", "global", "language", "login". Unexpected keys will be ignored.
Apologies if this isn't the right place to post this but I'm sure many others may have this problem and it might just be a lack of knowledge on my part related to how store enhancers such as redux-offline should be implemented, cheers!
How do we use this fork? Are there any significant differences? I tried to simply replace the imports:
import { offline } from '@redux-offline/redux-offline';
import offlineConfig from '@redux-offline/redux-offline/lib/defaults';
However, if I just do this the application constantly shows me that it's offline. Any clue what could have gone wrong?
Thanks in advance!
Just testing out this package and noticed a few deprecated warnings:
NetInfo.fetch() is deprecated. Use NetInfo.getConnectionInfo() instead
NetInfo's "change" event is deprecated. Listen to the "connectionChange" event instead
Hello!! I know that in the original repo this issue is affecting a lot of users. In this fork we never got to merge the PR into our code, this was because we never got around to test it. And we weren't able to replicate it. I suppose that in our app we never met the necessary conditions.
Moreover, I think that this is a BIG issue and a lot of people are waiting for it to be merged in the original repo. I think we should test the PR and if everything seems to be ok, we should merge it into our codebase.
What do you guys think? @bsouthga @wacii @sebasgarcep @j8seangel
I wanted a way for users to provide code reproducing errors in bug reports without creating a new repo, and found some success with https://codesandbox.io.
An example demonstrating the old DevTools issue: link.
A basic starting point: link.
We could provide links to these as well as the example app when a user fails to adequately describe the bug they are reporting.
This should be mentioned in the contributing section, but as we have not discussed this before, I thought I would ask if there's anything else we wanted to add. It might end up saving us a good deal of time in the long run.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.