Simple & Efficient state management library for React.js.
What is oolong
Oolong is a traditional semi-oxidized Chinese tea.
Oolong or "Wulong" is a Chinese term. It roughly translates to "own goal" in English. The term "own goal" refers to a situation in sports, particularly in soccer, when a player inadvertently scores a goal against their own team. The term "wulong" was adopted by Hong Kong journalists in the 1960s and 1970s to translate "own goal" because of its similar pronunciation and its connotations of making a mistake or being confused in Cantonese.
- Install
oolong/reactpackage to your React.js project
npm i @oolong/react- Create a
counterStore
import{createStore}from"@oolong/react";constcounterStore=createStore(0);functionApp(){// subscribe count valueconstcount=counterStore();return(<div>
counter: {count}{/* update the count */}<buttononClick={()=>counterStore.set((prev)=>prev+1)}>
Increment
</button></div>);}- Done!
Create a external store for your states is easy with Oolong. You may define a type of the store by passing it to createStore.
import{createStore}from"@oolong/react";typeTodo={id: string;title: string;completed: boolean;};interfaceTodoStore{todos: Todo[];}// pass a initial stateexportconsttodoStore=createStore<TodoStore>({todos: [],});Caveat : you should always create a store outside of any React component.