Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I manually prompt Redux Offline to process items in its outbox? #546

Open
mastadong opened this issue Mar 17, 2023 · 0 comments
Open

Comments

@mastadong
Copy link

mastadong commented Mar 17, 2023

As far as I can tell, Redux Offline (RO) relies on changes in navigator.onLine to determine online status. This is problematic because it's unreliable. I wrote a small function that pings our API to test the connection, so I have two questions:

  1. Is 'detectNetwork' the proper place to implement my ping method? Documentation and research are unclear as to exactly when this method gets called.

  2. Instead of using 'detectNetwork', suppose I manually handle pinging the network, dispatching the "Offline/STATUS_CHANGED" with the result, and synchronizing the redux store. The question is, how do I manually prompt RO to begin processing items in its outbox?

Here is how I have implemented RO in my React/Typescript application:

import offlineConfig from '@redux-offline/redux-offline/lib/defaults';
import reducers from './reducers';
import persistCallback from './middleware/persistCallback';

const customConfig = {
  ...offlineConfig,
  persistCallback: persistCallback,
};

export const store = configureStore({
  reducer: reducers,
  enhancers:[offline(customConfig)]
});

If anyone has a picture or a timeline of how RO is operating, that would be a great addition to the documentation.

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

No branches or pull requests

1 participant