Skip to content

Instantly share code, notes, and snippets.

@rococodogs
Last active August 19, 2016 22:24
Show Gist options
  • Select an option

  • Save rococodogs/9072d2df84b64c2d7bcc33e9b875302b to your computer and use it in GitHub Desktop.

Select an option

Save rococodogs/9072d2df84b64c2d7bcc33e9b875302b to your computer and use it in GitHub Desktop.
metadb store living document

metadb store document

this'll allow for commenting + discussion + editing, probably better than a doc in the repo (or an issue, for that matter)

In the latest big-changes commit, I've moved towards normalizing how each API request is stored within the store. The major root-level keys (work, vocabulary, terms) currently have the following structure:

{
	isFetching: boolean,
	isSaving: boolean,
	fetchedAt: number,   // Date.now()
	data: object, 	     // (maybe/possibly arrays too?)
	saved: boolean,			 // whether or not the current 'thing' has been saved
	updates: object,     // matches `data` format
	updated: boolean,
}

So a currently-active work would look like:

{
  // ...
  work: {
    isFetching: false,
    isSaving: false,
    fetchedAt: 1471645363265,
    data: {
      title: ['Example Work'],
      // ...
    },
    saved: false,
    updates: {
      title: ['Example Work', 'Alt. Title'],
      // ...
    },
    updated: true
  },
  // ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment