Reim
Github
2.0.0
2.0.0
  • Reim.js
  • Introduction
    • Motivation
    • Concepts
  • Guide
    • Store
    • setState
    • Subscribe
    • Plugin
    • Event Emitter
    • Use with React / Preact
    • Use with Vue
    • Use with Angular / Rxjs
  • Ecosystem
    • react-reim
    • reim-task
    • reim-reporter
    • reim-persist
    • Release Notes
Powered by GitBook
On this page
  • What is store?
  • Creating a store
  • Creating a named store
  • Adding plugins
  1. Guide

Store

What is store?

The Store is holds the state, and is responsible for change of state. You can also subscribe to a store for changes.

Creating a store

stores/todo.js
import reim from 'reim'

const todoStore = reim({
    todos: []
})

export default todoStore

Creating a named store

A store is anonymous by default. You can create a named store for use with plugins e.g. reim-reporter.

const todoStore = reim({
    todos: []
}, {
    name: 'Todo-Store'
})

Adding plugins

You can easily apply plugins on store

import react from 'react-reim'

const store = reim({message: ''}, {
    plugins: [react()]
})

or after it is initialized

const store = reim({}).plugin(persist())
PreviousConceptsNextsetState

Last updated 6 years ago