Code Monkey home page Code Monkey logo

redux-offline's People

Contributors

birgernass avatar dabit1 avatar elf-pavlik avatar evanwillms avatar fabriziomoscon avatar hajjitarik avatar hankmccoy avatar j8seangel avatar jaulz avatar jevakallio avatar jthegedus avatar kbrandwijk avatar mbrookes avatar mcpo avatar migueloller avatar piranna avatar sashasirotkin avatar sebasgarcep avatar sedubois avatar sorodrigo avatar wacii avatar zmarouf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

redux-offline's Issues

Usage with redux-logger

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)
));

Commit and Rollback should be optional

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

How to implement delayed send

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.

network detector is weird / misdocumented

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

  • No error is raised if you pass a boolean, an action Offline/STATUS_CHANGED is trigger with an empty payload object.
  • I'd expect the code to use a boolean value as documented

I can provide a fix, I guess that'd be a breaking change, let me know if that's fine.

Uncaught ReferenceError: regeneratorRuntime is not defined

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.

Add Changelog

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.

conceptual question

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.

Chaining Commit with another Action

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.

Unexpected key offline in preloaded state

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

Immutable root state

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

thoughts on switching to typescript?

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.

Expose constants

Could we please expose constants so we could react on REHYDRATE actions?

Not able to fulfill peer dependencies of redux-offline@^2.0.0

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.

Disconnect fork?

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?

Implement manual sync?

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.

Add `getState` to effect reconciler

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?

Include prettier

There has been some conversations about including prettier, just a reminder to do it someday.

Remove `console.log` statements

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.

Override queue?

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?

Usage with non-Immutablejs React-Boilerplate

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!

Difference to redux-offline?

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!

NetInfo deprecated warnings

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

Offline outbox not restored from redux-persist

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

Contributing Guidelines

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.