Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Implement non blocking mutate functions #2

Closed
wtrocki opened this issue Apr 10, 2019 · 1 comment
Closed

Implement non blocking mutate functions #2

wtrocki opened this issue Apr 10, 2019 · 1 comment
Assignees

Comments

@wtrocki
Copy link
Contributor

wtrocki commented Apr 10, 2019

Definition of the problem

Offline requests block promises.
This will mean that code in then will never be called until the device becomes online.

return this.apollo.mutate<Task>().then((retry)=>{
	// Never called when offline.
	// This will be resolved only when online
}).catch((error)=>{
	// Never called when offline
	// This will be resolved only when online
});

Proposal 1

Return error when change is enqueued offline and resubmit every change using client.

return this.apollo.mutate<Task>().then((retry)=>{
   // Never called when offline.
   // This will be resolved only when online
}).catch((error)=>{
  if(error.conflict){
    // User will get error with conflict
  }
});

Proposal 2

Return another observable or promise in error

return this.apollo.mutate<Task>().then((retry)=>{
   // Never called when offline.
   // This will be resolved only when online
}).catch((error)=>{
  if(error.offlinePromise){
    offlinePromise.then((data)=>{
       // Will be called when we become back online
    });
  }
});
@wtrocki wtrocki self-assigned this Apr 15, 2019
@wtrocki wtrocki mentioned this issue Apr 15, 2019
8 tasks
@wtrocki
Copy link
Contributor Author

wtrocki commented Apr 17, 2019

done in #10

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

No branches or pull requests

1 participant