CyStore Introduction - CyComponent/CyFramework GitHub Wiki

There's often a need to store and share related chunks of data in a front end web application. For example, many CyComponents need to share a collection of objects that represent networks. Some CyComponents modify this collection by allowing users to edit networks, and others simply display network data in a graphical or tabular format. It would become very expensive to hold a copy of the network data in each Component, and handle the complexity of exchanging data between CyComponents and CyComponent users.

CyStores allows you to store your data in once place that all interested parties can access, and provide a well defined API for mutating that data. CyStores live inside the CyFramework. You register CyComponents and CyStores when you initialize a new instance of the framework, and then the framework handles the scaling of all stores, and provides an API to dispatch actions to the stores and retrieve there state.

All store use the same API, however, stores can be package differently depending upon whether they make sense as only part of one component, or as a shared store between multiple components and users. We call these internal versus external stores.


####Internal CyStore A CyStore which a CyComponent creates for itself to handle state that only makes sense for that Component, like internal bookeeping of button clicks, toggles, etc. Each Cycomponent can create any number of CyStores. When you create an instance of the CyFramework, you will need to register the CyComponents that have store, so that the framework can initialize those stores before rendering components.

####External CyStore A CyStore that stands by itself, with many consumers. These stores usually store important application data like the working set of networks, centralized user information, etc. You create external CyStores as discrete projects using the CyStoreScaffold. To initialize these stores, you must pass these valid store objects to the CyFramework upon initialization, just as you would with a CyComponent.