question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Optimistic Response is not generated while offline or bad internet connection

See original GitHub issue

Bug Report

Hey, awesome project! I used a custom written wrapper for our offline support before but switching to a maintained project is way better.

I implemented offix in our messaging app and everything seems to work fine but I can’t get our optimistic response to work. The problem is that everytime I try to send a message into a chat while I’m offline it does not generate the optimistic UI for the message so you have to wait until the client gets back online to see the optimistic UI for a second and then you see the actual message responded by the server.

Am I missing something or doing something wrong? This is how we send the mutation:

client.offlineMutate({
  idField: 'id',
  mutation: SEND_MESSAGE,
  optimisticResponse,
  update: () => sendMessageUpdate(chatId),
  variables: {
    chatId,
    clientGeneratedUUID: messageUUID,
    forwardedMessages: [],
    images: mappedImages,
    message,
  },
})

the optimistic response itself is self generated but just looks fine (and it’s working when I’m online).

Do I have to do something to actually get the optimistic UI while offline?

  • Affected Package(s): offix

  • Package version(s): 0.13.1

  • Platform (e.g. Android/iOS): iOS and Android

  • Platform Version: RN 0.61.5 React 16.9.0

  • Cordova Version: x

  • Node.js / npm versions: Node: v11.15.0 NPM: 6.7.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
bdbchcommented, Jan 28, 2020

You were right, I had a problem in my sendMessageUpdate function. It works again. As I can see offix does not cache the update functions between app sessions so when I restart the app while offline, the update functions are gone right?

https://offix.dev/docs/offline-client#global-update-functions

The documentation here isn’t really clear. Do you have an good example on how those global update functions should look like? I’m trying to keep my sent offline messages when the app is restarted but I can’t get it working.

1reaction
wtrockicommented, Jan 28, 2020

We have documentation on the website http://offix.dev Source code for that documentation can be found here: https://github.com/aerogear/offix/tree/master/docs

We are happy to accept contributions

Read more comments on GitHub >

github_iconTop Results From Across the Web

Implement an Optimistic Response to a React UI ... - Egghead.io
In this lesson, we'll show how you can have your mutations work when the user is offline. We'll handle the offline mutation with...
Read more >
Offline-First Approach for Mobile Apps: React Native and Apollo
What happens when your app is used in the real world and there's no guarantee of decent internet connection? Does the app become...
Read more >
Offline first with react-native - Medium
Offline first applications, while still requiring a connection to the servers, don't need a constant internet connection.
Read more >
Working Up to an Optimistic Response in Apollo Client with ...
Use the network tab in the developer tools in your browser for testing like this. In Chrome you can set the network speed...
Read more >
Optimistic mutation results - Apollo GraphQL Docs
If our app is wrong (e.g., the GraphQL server returns an unchanged Comment due to an error), the UI will automatically update to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found