Revelry Data is a library for managing data within React applications using JSON API and Flux architecture. Provides a base Store object plus JSON API suitable patches for Backbone.


License
BSD-3-Clause
Install
gem install revelry_data -v 0.1.6

Documentation

RevelryData

Revelry Data is a library for managing data within React applications using JSON API and Flux architecture. It goes beyond most Flux implementations by having opinions on how data interchange with the server should work.

Currently, only the Store portion of Flux is truly implemented. Dispatcher and Action Creator portions are on the drawing board, but for now, methods on the store are acting as the actions, and we expect you to not twiddle data in the store directly from your components.

Documentation

We are actively commenting the library with jsDoc style comments, and are building the doc site for Revelry Data. In the meanwhile, the library is thoroughly commented.

Concepts

Stores

A store is a thing that holds data. This data might be something you persist to the server or not. The store also hold all the logic for manipulating the data. You should not directly write data to the store from your components. Your component only reads data from the store for display and dispatches actions when it needs data updated (currently, actions are just methods on the store object, so you can add your own by adding more methods).

Stores generally hold one or more models or collections.

Resources and Resource Types

When this library says "Resource", it means in the sense of "API Resource" and "REST API". It is a bit of data, with a type, that is meant to be read from the server and/or saved to the server. Our resources are set up as per the JSON API format.

Models

Just like in any MVC Framework, Models are objects which hold all the data that represents one "thing" or resource. Our models are just Backbone models.

Collections

Collections hold a list of related models of the same type. We use Backbone collections.

Paths

Many of the methods available in the base store reference data using "paths." Paths are strings which describe how to find the data in the store. They look like the JS code you would use to access a bit of data in the store. For example, the path 'beer' on store goes to store.beer. The path beer.IBUs goes to store.beer.IBUs. If you had a collection called beers on store, you could access the first beer's IBUs like 'beers.models[0].IBUs'.

Technically, these are JSONPaths, but you probably just need to know what is in the paragraph above to get around.

Relationships

We manage the relationships between models using the JSON API format. This means we do not nest related resources within the model itself. Instead we keep a reference to the related item in the special .relationships area of the model. This reference is an object containing just the id and type of the related item. We can use this information to look up the item in a collection of its type.

Getting Started

TBD

Testing

RAILS_ENV=test bake spec spec:javascript