Skip to content

Latest commit

 

History

History
60 lines (35 loc) · 2.19 KB

core-concepts.md

File metadata and controls

60 lines (35 loc) · 2.19 KB

Core concepts

ℹ️ This documentation is in progress.

Store and Scope

ℹ️ Good to know

  • The store is where you manage the state of your application.
  • The scope of the store is responsible for its internal functioning, you do not have to worry about that.

To not pollute the scope of a store, all methods related to state processing are in the scope property of the store (myStore.scope).

To improve productivity, the most used methods can be accessed directly as store methods.

Here is the list of shortcuts:

Store Scope
this.getState() this.scope.getState()
this.setState() this.scope.setState()
this.replaceState() this.scope.replaceState()
this._dispatch() this.scope.dispatch()
this._save() this.scope.save()

Flux pattern

The Flux pattern was primarily promoted by React.js. You can discover more about the Flux pattern in the React.js documentation.

This chapter is not intended to learn the Flux pattern. A short explanation (taken from the doc of React.js), the data in a Flux application flows in a single direction:

Flux Pattern

This structure allows us to reason easily about our application in a way that is reminiscent of functional reactive programming, or more specifically data-flow programming or flow-based programming, where data flows through the application in a single direction — there are no two-way bindings. Application state is maintained only in the stores, allowing the different parts of the application to remain highly decoupled. Where dependencies do occur between stores, they are kept in a strict hierarchy, with synchronous updates managed by the dispatcher. -- From React.js documentation

Flux Pattern

When you use the actions in Storux, you use the Flux pattern. Storux manages this for you 💪

Actions

TODO

Actions and hooks

TODO

Create a store that has actions

TODO

Create a store that has actions and hooks

TODO