simpler-state
Advanced tools
Comparing version 1.0.0-rc.3 to 1.0.0-rc.4
import { useState, useCallback, useEffect } from 'react'; | ||
import { strictEqual } from './utils'; | ||
var identity = function identity(v) { | ||
return v; | ||
}; | ||
export var useEntity = function useEntity(entity, transform, equality) { | ||
if (transform === void 0) { | ||
transform = function transform(v) { | ||
return v; | ||
}; | ||
transform = identity; | ||
} | ||
@@ -9,0 +12,0 @@ |
@@ -10,7 +10,9 @@ "use strict"; | ||
var identity = function identity(v) { | ||
return v; | ||
}; | ||
var useEntity = function useEntity(entity, transform, equality) { | ||
if (transform === void 0) { | ||
transform = function transform(v) { | ||
return v; | ||
}; | ||
transform = identity; | ||
} | ||
@@ -17,0 +19,0 @@ |
{ | ||
"name": "simpler-state", | ||
"version": "1.0.0-rc.3", | ||
"version": "1.0.0-rc.4", | ||
"description": "The simplest app state management for React", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -11,6 +11,6 @@ # <img src="https://simpler-state.js.org/assets/simpler-state-logo.png" alt="SimpleR State" width="240"/> | ||
- __Minimalist API__; no complicated concepts or boilerplate | ||
- Just use __plain functions__ to update state | ||
- Use __plain functions__ to update state (including async) | ||
- Largely __unopinionated__ with flexible syntax | ||
- Extremely __simple to unit test__ state logic | ||
- Highly extensible with __plug-ins__ | ||
- Highly extensible with __plug-ins__ (e.g. persistence, dev tools) | ||
- Full __TypeScript__ support with uncomplicated types | ||
@@ -37,8 +37,8 @@ - Made specifically for React, and built on __React Hooks__ | ||
export const increment = by => { | ||
counter.set(counter.get() + by) | ||
export const reset = () => { | ||
counter.set(0) | ||
} | ||
export const decrement = by => { | ||
counter.set(counter.get() - by) | ||
export const increment = by => { | ||
counter.set(value => value + by) | ||
} | ||
@@ -50,7 +50,6 @@ ``` | ||
```jsx | ||
import { useEntity } from 'simpler-state' | ||
import { counter, increment, decrement } from 'counter' | ||
import { counter, increment, reset } from 'counter' | ||
const CounterView = () => { | ||
const count = useEntity(counter) | ||
const count = counter.use() | ||
@@ -62,3 +61,3 @@ return ( | ||
<button onClick={() => increment(1)}> + </button> | ||
<button onClick={() => decrement(1)}> - </button> | ||
<button onClick={reset}> Reset </button> | ||
</> | ||
@@ -69,7 +68,7 @@ ) | ||
It's that simple! | ||
It's that simple! __But the library can do a lot more.__ | ||
## Documentation | ||
Learn more about SimpleR State at [simpler-state.js.org](https://simpler-state.js.org). | ||
Learn more about what you can do with SimpleR State at [simpler-state.js.org](https://simpler-state.js.org). | ||
@@ -76,0 +75,0 @@ ## Feedback |
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
21523
403
79