BlueChip
BlueChip helps you manage your data in a consistent way when working with client-side JavaScript state management systems.
Last updated
BlueChip helps you manage your data in a consistent way when working with client-side JavaScript state management systems.
Last updated
https://github.com/mfpiccolo/blue-chip
https://www.npmjs.com/package/blue-chip
There are only two things that BlueChip does.
Normalize data and organize it in a store.
Retrieve the data from the store and prepare it for use.
BlueChip will take your data, normalize it and place it into a shared resources store. The API on this side is pretty minimal.
updateResources() - Takes an entire payload of resources, normalize it and merge it into the store.
updateResource() - Merges in a single resource into your store
removeResource() - Self explanatory. Yay self documenting code!
And that is it for the State API.
This is the meat of BlueChip. The selector API is how you prepare your data to be consumed by components. To select data, BlueChip offers a robust ORM-style syntax complete with models, relationships, filtering, includes and more. You only needs access to the resources store to be able to use the selector api.
Here is an example of using the ORM syntax to select from the store
BlueChip is not interested in how you get your data. Fetch it, mock it, import it. However you get your data that is your business. The only requirement is that your data is formatted according to one of the adapters (JsonAPI, GraphQL). If it is not formatted you can write a custom adapter to normalize it.
BlueChip is agnostic to which client-side state management library you choose to use (Redux, Mobx, Vuex, other). You only need access to a shared resources store for BlueChip to work.
You have multiple data sources (or multiple projects with different data sources) and want to consistently interact with all of them in the same way in your client-side state management systems. You can easily normalize and connect components from GraphQL, JsonAPI and custom formatted API's.
You already have a state manager that you like or is a requirement of a project and do not want to adopt multiple to handle both GraphQL and JSON Rest data.
You would like to keep resources unnessted in your stores for ease of updating, simplicity of mutation schema and ability to easily share resources across your application.
You are familiar with and prefer using ORM's when querying and working with data.
To start, choose your state management flavor. This is an example using Redux.
Or
Batch update resources:
Update a single resource:
Just like any other ORM you will be defining model classes:
The resources store is structured as an object with top-level keys as pluralized resource names.
Each resource key points to an object that contains ids as keys and an JSON api object as a value.
This project is currently in Alpha/Experimental phase. The APIs will almost assuredly change prior to 1.0. It is not ready for production yet so use at your own risk. There are also unfinished features like MobX adapter
belongsTo relationship
Add Unstated adapter
Change API to be more modular to allow for configuring adapters
Memoization