All Projects → will123195 → venti

will123195 / venti

Licence: other
⚛️ Global State for React

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to venti

snap-state
State management in a snap 👌
Stars: ✭ 23 (+43.75%)
Mutual labels:  state
vue-reactive-store
A VueX alternative : declarative + reactive + centralized way to structure your data store. Inspired by VueX and Vue.js . Compatible with vue-devtools.
Stars: ✭ 27 (+68.75%)
Mutual labels:  state
deep-state-observer
State library for high performance applications.
Stars: ✭ 25 (+56.25%)
Mutual labels:  state
mafuba
Simple state container for react apps.
Stars: ✭ 20 (+25%)
Mutual labels:  state
public salaries
Public sector employee salaries
Stars: ✭ 16 (+0%)
Mutual labels:  state
rxact
Rxact is an observable application management for Javascript app
Stars: ✭ 21 (+31.25%)
Mutual labels:  state
stateware
Smart state container with easy copy and auto memoized getters
Stars: ✭ 20 (+25%)
Mutual labels:  state
agile
🌌 Global State and Logic Library for JavaScript/Typescript applications
Stars: ✭ 90 (+462.5%)
Mutual labels:  state
ReduxSimple
Simple Stupid Redux Store using Reactive Extensions
Stars: ✭ 119 (+643.75%)
Mutual labels:  state
xstate
State machines and statecharts for the modern web.
Stars: ✭ 21,286 (+132937.5%)
Mutual labels:  state
boutique
Immutable data storage
Stars: ✭ 44 (+175%)
Mutual labels:  state
temperjs
State management for React, made simple.
Stars: ✭ 15 (-6.25%)
Mutual labels:  state
csgo-gsi
A Java library for Counter-Strike: Global Offensive's game state integration
Stars: ✭ 23 (+43.75%)
Mutual labels:  state
rex-state
Convert hooks into shared states between React components
Stars: ✭ 32 (+100%)
Mutual labels:  state
tstate-machine
TypeScript implementation of State Manager(like StateMachine)
Stars: ✭ 20 (+25%)
Mutual labels:  state
elf-ng-router-store
Bindings to connect Angular router to Elf
Stars: ✭ 20 (+25%)
Mutual labels:  state
react-apollo-mutation-state
A React HOC wrapper for Apollo GraphQL mutation, provides loading and error in props
Stars: ✭ 16 (+0%)
Mutual labels:  state
react-drip-form
☕ HoC based React forms state manager, Support for validation and normalization.
Stars: ✭ 66 (+312.5%)
Mutual labels:  state
useSharedState
useSharedState is a simple hook that can be used to share state between multiple React components.
Stars: ✭ 0 (-100%)
Mutual labels:  state
okito
Your best flutter coding friend. All in one; state management, navigation management(with dynamic routing), local storage, localization, dependency injection, cool extensions with best usages and with the support of best utilities!
Stars: ✭ 37 (+131.25%)
Mutual labels:  state

Venti

Global State for React

Build Status

Install

npm i venti

Quick Start

Get global state

import React from 'react'
import { useVenti } from 'venti'

export default function Book({ id }) {
  const state = useVenti()
  const { author, title } = state.get(`books.${id}`, {})
  const year = state.get(`books.${id}.year`)
  return <div>"{title}" by {author} ({year})</div>
}

Set global state

import { state } from 'venti'

state.set('books.1', {
  author: 'John Steinbeck',
  title: 'Cannery Row',
  year: 1945
})

API

useVenti( [state] )

  • state {State} (optional) defaults to singleton state if not provided
  • Returns state that has been instrumented to update the component when applicable
  • See StateEventer for more info

state.get( path, [defaultValue] )

  • path {Array|string} The path to get
  • defaultValue {*} (optional) The value returned for undefined resolved values
  • Returns the resolved value

state.set( path, value )

  • path {Array|string} The path of the property to set
  • value {*} The value to set

state.unset( path )

  • path {Array|string} The path of the property to unset

state.update( path, transformFn, [defaultValue] )

  • path {Array|string} The path of the property to set
  • transformFn {Function} transforms the current value to a new value
  • defaultValue {*} (optional) the default value to pass into the transform function if the existing value at the given path is undefined
    state.update('counter', n => n + 1, 0)

Advanced Usage

If you don't want to use Venti's singleton state, you can do this:

import React from 'react'
import { State, useVenti } from 'venti'

const globalState = new State()
const useGlobalState = () => useVenti(globalState)

export default function Book({ id }) {
  const state = useGlobalState()
  const { title, year } = state.get(`books.${id}`)
  return <div>{title} ({year})</div>
}

Performance Benchmarks

Color Matrix Benchmark

Examples

Tests

npm test

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].