simpler-state
Advanced tools
Comparing version 1.0.0-beta.2 to 1.0.0-beta.3
@@ -5,3 +5,3 @@ export function entity<T = any>(initialValue: T): Entity<T> | ||
entity: Entity<T>, | ||
options: { | ||
options?: { | ||
transform?: (value: T) => C | ||
@@ -8,0 +8,0 @@ equalityFn?: (a: any, b: any) => boolean |
{ | ||
"name": "simpler-state", | ||
"version": "1.0.0-beta.2", | ||
"version": "1.0.0-beta.3", | ||
"description": "The simplest app state management for React", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -10,16 +10,20 @@ # SimpleR State | ||
It is part of the upcoming __SimpleR__ collection of all things that make React development a breeze. This library is an evolution of [__React Entities__](https://github.com/arnelenero/react-entities). | ||
This library is an evolution of [__React Entities__](https://github.com/arnelenero/react-entities). | ||
## Two Easy Steps! | ||
__Step 1:__ Create an entity (shared state) and actions | ||
__Step 1:__ Create an entity (shared state) and actions (updater functions) | ||
```js | ||
const counter = entity(0) | ||
// counter.js | ||
const increment = by => { | ||
import { entity } from 'simpler-state' | ||
export const counter = entity(0) | ||
export const increment = by => { | ||
counter.set(counter.get() + by) | ||
} | ||
const decrement = by => { | ||
export const decrement = by => { | ||
counter.set(counter.get() - by) | ||
@@ -29,5 +33,8 @@ } | ||
__Step 2:__ Use the entity in your components | ||
__Step 2:__ Use the entity in your components with hooks | ||
```jsx | ||
import { useEntity } from 'simpler-state' | ||
import { counter, increment, decrement } from 'counter' | ||
const CounterView = () => { | ||
@@ -47,2 +54,2 @@ const count = useEntity(counter) | ||
It's that simple! | ||
It's that simple! |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15177
53