Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/saasquatch/bunshi
Molecule pattern for jotai, valtio, zustand, nanostores, xstate, react and vue
https://github.com/saasquatch/bunshi
dependency-injection react vue
Last synced: 3 months ago
JSON representation
Molecule pattern for jotai, valtio, zustand, nanostores, xstate, react and vue
- Host: GitHub
- URL: https://github.com/saasquatch/bunshi
- Owner: saasquatch
- License: mit
- Created: 2022-03-31T16:39:53.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-27T23:28:33.000Z (6 months ago)
- Last Synced: 2024-05-28T04:56:10.169Z (6 months ago)
- Topics: dependency-injection, react, vue
- Language: TypeScript
- Homepage: https://www.bunshi.org/
- Size: 2.1 MB
- Stars: 191
- Watchers: 8
- Forks: 11
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
![Jotai (light mode)](./logo/bunshi.svg)
# Bunshi (formerly `jotai-molecules`)
- **[Documentation](https://bunshi.org)**
A tiny, fast, dependency-free 3kb library for creating states stores and other dependencies that lets you lift state up or push state down. Works out of the box with React, Vue and vanilla javascript and Typescript.
> Definition: Bunshi (分子 / ぶんし) - Japanese for molecule, member or element.
Works well with state solutions like:
- [jotai](https://jotai.org/) atoms
- [valtio](https://valtio.pmnd.rs/) proxies
- [zustand](https://zustand-demo.pmnd.rs/) stores
- [nanostores](https://github.com/nanostores/nanostores)
- [vue reactive](https://vuejs.org/guide/scaling-up/state-management.html#simple-state-management-with-reactivity-api)Comes out of the box with support for:
- React
- Vue
- Vanilla Javascript & TypescriptSee [the docs](https://bunshi.org) for more details on why we created this library and how to use it.
Inspired by [jotai](https://jotai.org/) and [guice](https://github.com/google/guice).
## Installation
This module is published on NPM as `bunshi`
```sh
npm i bunshi
```## Documentation
Check out the docs on [bunshi.org](https://bunshi.org).
## Migrating from jotai-molecules
Coming from an older version of jotai-molecules? The core API and functionality is the same, but bunshi no longer
assumes react as the default use case.```diff
import { atom } from "jotai"
- import { molecule, useMolecule } from "jotai-molecules"
+ import { molecule, useMolecule } from "bunshi/react"const countMolecule = molecule(()=>atom(0));
const Counter = ()=>{
const [count,setCount] = useAtom(useMolecule(countMolecule));
return
Count is {count}
setCount(c=>c+1)}>Increment
}
```