Giter VIP home page Giter VIP logo

redux-offline-examples's Introduction

Examples for Redux-Offline

Apollo Web Demo

Quick start

Simple Web

First Terminal
cd server-json
npm install
npm start
Second Terminal
cd simple-web
npm install
npm start

Apollo Web

Terminal
cd apollo-web
npm install
npm start

redux-offline-examples's People

Contributors

mananruck 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

Watchers

 avatar  avatar  avatar

redux-offline-examples's Issues

Mutation completes, but subsequent action call and redirect not working

I'm having a bit of an issue whereby upon firing a login mutation 'data' returns a user token. The token should then be stored via an action call, and the user is then redirected to the main site.

But the token action and the redirect are not acted upon, and the action to complete a user login simply continues to cycle round over and over (See image).

What is the issue here?

store.js

        effect: (effect, action) => {
          switch (effect.type) {
            case 'query':
              return client.query({...effect}).then(({data}) => data);
            case 'mutation':
              return client.mutate({...effect})
              .then(({data}) => {
                store.dispatch(authToken(data.signinUser.token));
                this.context.router.history.push('/');
              });
            default:
          }
        }

error

Doesn't work offline

I tried to open the website while offline, after having opened it while online, but the page doesn't load. Tested on iPhone safari. iOS 10.3.1.

Go Offline -> Add todo -> Remove todo -> Go Online

Summary

If you create a todo item while offline, whatever mutation you apply to edit does not trigger. This is understandable as it has no ID yet and following mutation won't work.

I know this is just a proof-of-concept, but do you have any ideas how to approach this problem? I'm toying around with doing an offline-first Apllo RN app so basically just started googling offline-support 20min ago. Haven't thought about it much myself, I might have a play around in the next few days.

.. Also, related, if you you crazy tick/untick the checkbox whilst offline, you'll have a myriad of queued requests. Might be two problems to solve at the same time, or it might not. ๐Ÿคทโ€โ™‚๏ธ

STR

  1. Load page
  2. Set to offline
  3. Add todo item
  4. Remove todo item
  5. Go online
  6. Hard-refresh page

Expected

Added todo item should be not have been added (or added and instantly removed)

Actual

Said todo item is in place

Notes

Same thing with any mutation. I.e. add item while offline -> update to checked -> go online -> refresh page

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.