Greed Optimistic Updates
Last updated 4 years ago by kennetpostigo .
MIT · Original npm · Tarball · package.json
$ cnpm install greed-optimist 
SYNC missed versions from official npm registry.


A Greed Plugin for Optimistically Updating Data

Travis Codecov branch version downloads Donate MIT License

This modules purpose is to provide a solution for optimistically updating data and the views that depend on it. This module should be placed on the greed options object.


npm install --save greed-optimist


import Greed from 'greed';
import optimist from 'greed-optimist';

var gql = Greed({
  url: 'https://localhost:3000/',
  token: 'someCrazySuperSecretToken',
  plugins: {
    pre: [
    post: [


  count(id: 2){
}`, optimistic, success, fail);

You simply add the greed-optimist to the options plugin field and the plugin adds three parameters to the returned function call. The parameters takes three functions one is handler for what to update immediately when you make the request, this is the "optimistic" update, then success and failure handlers, the handle those 2 respective outcomes. You may be wondering whats the point of using this module if I'm still covering these cases. Great question! What this module enables is the ability to automatically rollback to the previous correct state. Meaning when a network request fails we automatically rollback the state/data to the previous correct state, and in turn updates all the views that depend on that data. Allowing your fail handler to show a notification, try again, etc. in response to the failure.



Current Tags

  • 0.2.1                                ...           latest (4 years ago)

1 Versions

  • 0.2.1                                ...           4 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
Dev Dependencies (0)
Dependents (0)

Copyright 2014 - 2016 © |