hero

Slim

Centralized State Management With Proxy, State-Non-Editable.

QuickStart →

Exquisite

Simple API and tiny volume。

Strong-Restriction

State updates are completely limited to reducers, and centralized management of update operations makes state changes more predictable。

Independently

Running independently of any framework.

TIP

Slim can be applied to any framework because it does not depend on any framework. Integration to frameworks will very easy by using Plugin.

Installation

CDN

<script src="https://unpkg.com/slim-store@latest/slim.min.js"></script>

NPM

npm install slim-store

Yarn

yarn add slim

Usage

import Slim from 'slim-store'

// state is single object
const state = {
    name: 'slim',
    age: 20
}

// reducers are event proxies
const reducers = {
    increment: (state) => {
        state.age += 1
    }
}

// getters are computed functions of state
const getters = {
  desc: state => `My name is : ${state.name}, I'm ${state.age}-years-old!`
}

// create store
const store = Slim.createStore({
    reducers,
    getters,
    state
})

// emit increment reducer
store.commit('increment')

console.log(store.state.count)
// output: 21

console.log(store.getGetter('desc'))
// output: My name is : slim, I'm 21-years-old!`

Extensions

  • VSlim: Slim-based state management framework in Vue.
  • RSlim: Slim-based state management framework in React.