A tiny state manager for React, Svelte, Vue and vanilla JS

Overview

dotto.x

dotto.x - lightweight state manager

Dotto.x is a tiny state manager for React, Svelte, and vanilla JS.

  • Lightweight. Core is less than 135 bytes (minified and gzipped). Zero dependencies.
  • Easy but strong. Simple working principle without magic but with all features from big state managers.
  • Deep observable. You can subscribe and follow pinpoint changes without thinking about multiple re-renders and memoization.
  • Strong plugin system. You can enhance your store with plugins. Logging, undoing changes, connecting Redux-devtools, and anything else.
  • Tree Shakable. All library is split into small modules.
  • Strong TypeScript support.



Status

⚠️ ⚠️ ⚠️

Project is in progress now. Please wait for version 1.0.0.

TODOS

  • Documentation
  • JSDoc comments
  • Vue, RN, Solid bindings
  • Examples on all frameworks

Installation

Using npm

npm i dotto.x

Using yarn

yarn add dotto.x

Basic usage

Atomic stores

import { createAtom } from 'dotto.x'

const userName = createAtom('John')

userName.listen(value => {
  // do something
})

userName.set('John Constantine')

Mutable stores

import { createStore } from 'dotto.x'

const user = createStore({ name: 'John' })

user.watch('name', value => {
  // do something
})

userName.set('name', 'John Constantine')

Computed

Combine your stores

Subscribe to store or part of stores using take.

import { createStore, computed, take } from 'dotto.x'

const user = createStore({ name: 'John', id: 'some_id' })
const projects = createStore({
  some_id: { name: 'Portfolio' },
  some_other_id: { name: 'Awesome Project' }
})

const targetProject = computed(() => {
  let userId = take(user, 'id')
  return take(projects, userId)
})

targetProject.subscribe(value => /* do something */)

user.set('id', 'some_other_id')

Computed operators

take

  • get value and subscribe to this paths

deep

  • get value and subscribe to all store

Use with React

Install dotto.x binding to React:

Using npm

npm i @dotto.x/react

Using yarn

yarn add @dotto.x/react

store.js

import { createStore, computed, take, update } from 'dotto.x'

const user = createStore({ name: 'John', id: 'some_id' })
const projects = createStore({
  some_id: { name: 'Portfolio' },
  some_other_id: { name: 'Awesome Project' }
})

export const targetProject = computed(() => {
  let userId = take(user, 'id')
  return take(projects, userId)
})

export const changeUser = newUser => {
  return update(user, () => newUser)
}

ProjectCard.jsx

import { useStore } from '@dotto.x/react'
import { targetProject } from './store'

export const ProjectCard = () => {
  const project = useStore(targetProject)
  return <div>{project.name}</div>
}
You might also like...
Toy Level Reactivity like Vue 3.x

reactivity Reactivity like Vue 3.x Features Typescript JSX Support Components and Fragment Dependency-Collect Reactivity Reactive Object based on ES6

A tiny, blazing fast view library that creates reactive Web Components

dlite A tiny, blazing fast view library that creates reactive Web Components 📖 Complete documentation https://dlitejs.com 🧐 Introduction dlite creat

The simple but very powerful and incredibly fast state management for React that is based on hooks

Hookstate The simple but very powerful and incredibly fast state management for React that is based on hooks. Why? • Docs / Samples • Demo application

🔍 Holmes is a 0 config, fast and elementary state orchestrator for React

React Holmes 🔍 - Elementary State Orchestrator for React 🔍 Holmes is a 0 config, fast and elementary state orchestrator for React. Holmes has a very

Immutable state for React.js
Immutable state for React.js

react-cursor Immutable state for React.js react-cursor hello-world in a fiddle What is react-cursor Cursors are a tool for working with recursive or d

Centrally manage state for React applications with CSP

State Trooper Install npm npm install state-trooper Yarn yarn add state-trooper Example Usage Call StateTrooper.patrolRunLoop in your route handler/ma

micro reactive state management - just for fun

effectus micro reactive state management - just for fun Install $ yarn add effectus Usage import { effect, signal } from 'effectus' const [name, set

A minimum and lightweight external store for React and React Native application

Reactive store - a minimum and lightweight external store for React and React Native application Table of contents Features Installation Usage 3.1 Cre

Maple.js is a React webcomponents based framework mixing ES6 with Custom Elements, HTML Imports and Shadow DOM. It has in-built support for SASS and JSX, including a Gulp task for vulcanizing your project.
Maple.js is a React webcomponents based framework mixing ES6 with Custom Elements, HTML Imports and Shadow DOM. It has in-built support for SASS and JSX, including a Gulp task for vulcanizing your project.

Heroku: http://maple-app.herokuapp.com/ npm: npm install maple.js Bower: bower install maple.js Maple is a seamless module that allows you to organise

Releases(0.4.1)
Owner
null
Teaful - Tiny, easy and powerful React state management

Tiny, easy and powerful React state management library What advantages does it have? ✨ ?? ・Tiny: Less than 1kb package to manage your state in

Teaful 668 Dec 18, 2022
A tiny, reactive JavaScript library for structured state and tabular data.

A JavaScript library for structured state. Using plain old JavaScript objects to manage data gets old very quickly. It's error-prone, tricky to track

tinyplex 1.4k Dec 30, 2022
An event-based global state management tool for vue, react, mini-program, ect.

hy-event-store An event-based global state management tool for vue, react, mini-program, etc. 一个基于事件的全局状态管理工具,可以在Vue、React、小程序等任何地方使用。 设计灵感 在项目中找到一个更加

null 260 Jan 2, 2023
React, React Native and Vue UI components for building data-driven apps with Elasticsearch

Reactive Search UI components library for Elasticsearch: Available for React, Vue and React Native Read how to build an e-commerce search UI a.) with

appbase.io 4.7k Jan 4, 2023
A tiny library aims to parse HTML to Figma Layer Notation and do it well.

TSDX User Guide Congrats! You just saved yourself hours of work by bootstrapping this project with TSDX. Let’s get you oriented with what’s here and h

青岚 5 Dec 28, 2022
A document head manager for React

React Helmet This reusable React component will manage all of your changes to the document head. Helmet takes plain HTML tags and outputs plain HTML t

National Football League 16.7k Dec 29, 2022
qiankun项目实践和优化(React+Vue)

qiankun项目实践和优化(React+Vue) 前言 qiankun微服务,将多个不同技术栈的系统(React,Vue,Angular,jQuery)等聚合成一个系统,各个系统又能各自独立部署运行,适用于大型团队和大型前端项目。 实现功能: 引入多技术栈(React + Vue) 后台管理系统(

Rick 30 Oct 31, 2022
basic implementation of the Vue 3 reactivity engine - from scratch

Vue 3 Reactivity This material was created by Marc Backes in order to show how reactivity is solved in Vue 3. It contains a basic implementation of th

Marc Backes 13 Oct 6, 2022
A tiny ( 1KB) reactivity library

influer A tiny (< 1KB) reactivity library yarn add influer Introduction influer is a tiny reactivity library. Exported in ESM, CJS, and IIFE, all < 1K

Tom Lienard 7 Jul 13, 2022
A reactive filesystem interface based on Vue 3 reactivity system.

A reactive filesystem interface based on Vue 3 reactivity system.

Guillaume Chau 37 Oct 8, 2022