All Projects → ktsn → Sinai

ktsn / Sinai

Licence: mit
Type safe state management inspired by Vuex

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Sinai

Hydux
A light-weight type-safe Elm-like alternative for Redux ecosystem, inspired by hyperapp and Elmish
Stars: ✭ 216 (+94.59%)
Mutual labels:  type-safe, state-management
Store
Aurelia single state store based on RxJS
Stars: ✭ 103 (-7.21%)
Mutual labels:  state-management
Iflow
Concise & powerful state management framework for Javascript.
Stars: ✭ 81 (-27.03%)
Mutual labels:  state-management
Use Substate
🍙 Lightweight (<600B minified + gzipped) React Hook to subscribe to a subset of your single app state.
Stars: ✭ 97 (-12.61%)
Mutual labels:  state-management
Freezer
A tree data structure that emits events on updates, even if the modification is triggered by one of the leaves, making it easier to think in a reactive way.
Stars: ✭ 1,268 (+1042.34%)
Mutual labels:  state-management
Go Structured Query
Type safe SQL query builder and struct mapper for Go
Stars: ✭ 101 (-9.01%)
Mutual labels:  type-safe
Radon
Object oriented state management solution for front-end development.
Stars: ✭ 80 (-27.93%)
Mutual labels:  state-management
Nucleo
🏋️‍♀️ Nucleo is a strongly typed and predictable state container library for JavaScript ecosystem written in TypeScript
Stars: ✭ 109 (-1.8%)
Mutual labels:  state-management
River pod
A simple way to access state while robust and testable.
Stars: ✭ 1,366 (+1130.63%)
Mutual labels:  state-management
Redux Reset
Give redux the ability to reset the state
Stars: ✭ 95 (-14.41%)
Mutual labels:  state-management
Sigi
Well designed effect management framework for complex frontend app
Stars: ✭ 95 (-14.41%)
Mutual labels:  state-management
Vuex Pathify
Vue / Vuex plugin providing a unified path syntax to Vuex stores
Stars: ✭ 1,281 (+1054.05%)
Mutual labels:  state-management
Homebase React
The React state management library for write-heavy applications
Stars: ✭ 101 (-9.01%)
Mutual labels:  state-management
Behavior Tree
🌲 Manage React state with Behavior Trees
Stars: ✭ 85 (-23.42%)
Mutual labels:  state-management
Faste
Component based 📦 Finite State Machine Manager 🤖
Stars: ✭ 105 (-5.41%)
Mutual labels:  state-management
Compare React State Management
React createContext vs Apollo vs MobX vs Redux in a simple todo app.
Stars: ✭ 81 (-27.03%)
Mutual labels:  state-management
Reactstatemuseum
A whirlwind tour of React state management systems by example
Stars: ✭ 1,294 (+1065.77%)
Mutual labels:  state-management
Momentum
MVC pattern for flutter. Works as state management, dependency injection and service locator.
Stars: ✭ 99 (-10.81%)
Mutual labels:  state-management
Datx
DatX is an opinionated JS/TS data store. It features support for simple property definition, references to other models and first-class TypeScript support.
Stars: ✭ 111 (+0%)
Mutual labels:  state-management
Visly State
React state for real-time apps
Stars: ✭ 106 (-4.5%)
Mutual labels:  state-management

Sinai

npm version Build Status sinai Dev Token

Type safe state management inspired by Vuex.

This library includes many type level hacks. Use at your own risk and do not use if you are unsure about the mechanism under the hood.

If you search a production ready state management solution, take a look vuex-smart-module

Requirements

  • Vue >= 2.5
  • TypeScript >= 2.8

Examples

import { store as createStore, module, Getters, Mutations, Actions } from 'sinai'

// Declare the module state and its initial value
class CounterState {
  count = 0
}

// Declare getters
class CounterGetters extends Getters<CounterState>() {
  get half () {
    return this.state.count / 2
  }
}

// Declare mutations
class CounterMutations extends Mutations<CounterState>() {
  inc () {
    this.state.count += 1
  }

  dec () {
    this.state.count -= 1
  }
}

// Declare actions
class CounterActions extends Actions<CounterState, CounterGetters, CounterMutations>() {
  asyncInc (ms: number) {
    console.log('count: ' + this.state.count)
    console.log('half: ' + this.getters.half)

    return new Promise(resolve => {
      setTimeout(() => {
        this.mutations.inc()
        resolve()
      }, ms)
    })
  }
}

// Create module by composing state/getters/mutations/actions
const counter = module({
  state: CounterState,
  getters: CounterGetters,
  mutations: CounterMutations,
  actions: CounterActions
})

// Create root module
const root = module().child('counter', counter)

// Create store
const store = createStore(root, {
  strict: process.env.NODE_ENV !== 'production'
})

// These will be all type checked
console.log(store.state.counter.count)
console.log(store.getters.counter.half)
store.actions.counter.asyncInc(1000)
store.mutations.counter.inc()

For other examples, see tests.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].