🌐 reway
💨 Flexible framework-agnostic state-manager.
Motivation
The main advantages and directions for the development of reway are:
- convenience
- speed
- code reuse, regardless of the framework
Documentation
-
Install library from npm
yarn add @reway/core
If you want to use more convenient tools for your framework, you can install additional packages (OPTIONAL)
P.S: Already we support only React.yarn add @reway/<framework-name>
-
Write a simple case:
import { atom } from "@reway/core"; type ExampleStore = { hello: string; } const example = atom<ExampleStore>({ hello: "me" })
-
Listen any actions
// You can listen for global changes in your atom by replacing "hello" (in the example above) with "data" example.on("hello", (state) => { console.log("Hello is changed!") })
-
Change data in atom
example.set({ hello: "not me" })
-
Get data
example.get() // You can also choose the line you want to get example.get({ hello: true })
-
Start using it in your project, and then share your opinion with us!
Advanced features
- combine
import {combine, atom} from "@reway/core"; const likes = atom<number>(0); const name = atom<string>("hello"); // The first parameter to the combine function is an array of keys for your values (optional). // The second parameter is the atoms. const post = combine(['likes', 'name'], likes, name) // The result is a default atom /* { likes: 0, name: "hello" } */ console.log(post.get()) likes.set(100) name.set("News") /* { likes: 100, name: "News" } */ console.log(post.get())
TODO
- Support for plugins (persists, etc.)
Contribution
The library needs your activity! We welcome any help.