simpler-state
Advanced tools
Comparing version 1.0.0-rc.7 to 1.0.0-rc.8-pre.0
@@ -80,3 +80,3 @@ import { useEntity } from './useEntity'; | ||
if (typeof plugin[method] === 'function') { | ||
var override = plugin[method](entity[method], entity.get, meta); | ||
var override = plugin[method](entity[method], entity, meta); | ||
if (typeof override !== 'function') throw new Error("Invalid override for '" + method + "' in plug-in '" + plugin.id + "'."); | ||
@@ -83,0 +83,0 @@ entity[method] = override; |
@@ -30,13 +30,2 @@ /** | ||
/** | ||
* Binds an entity to the component as a ref | ||
* @param entity - the entity | ||
* @param transform - optional data transformation function | ||
*/ | ||
export function useEntityRef<T>(entity: Entity<T>): T | ||
export function useEntityRef<T, C>( | ||
entity: Entity<T>, | ||
transform?: (value: T) => C | ||
): C | ||
export interface Entity<T> { | ||
@@ -67,7 +56,2 @@ init: () => void | ||
/** | ||
* Resets the values of all entities (for testing) | ||
*/ | ||
export function resetAll(): void | ||
/** | ||
* Attaches a plug-in to SimplerR State | ||
@@ -84,6 +68,6 @@ * @param pluginPkg - the plug-in package | ||
id: string | ||
init?: (origInit: () => void, get: () => any, meta: M) => () => void | ||
init?: (origInit: () => void, entity: Entity<any>, meta: M) => () => void | ||
set?: ( | ||
origSet: (...args: any[]) => void, | ||
get: () => any, | ||
entity: Entity<any>, | ||
meta: M | ||
@@ -90,0 +74,0 @@ ) => (...args: any[]) => void |
@@ -91,3 +91,3 @@ "use strict"; | ||
if (typeof plugin[method] === 'function') { | ||
var override = plugin[method](entity[method], entity.get, meta); | ||
var override = plugin[method](entity[method], entity, meta); | ||
if (typeof override !== 'function') throw new Error("Invalid override for '" + method + "' in plug-in '" + plugin.id + "'."); | ||
@@ -94,0 +94,0 @@ entity[method] = override; |
{ | ||
"name": "simpler-state", | ||
"version": "1.0.0-rc.7", | ||
"version": "1.0.0-rc.8-pre.0", | ||
"description": "The simplest app state management for React", | ||
@@ -28,4 +28,4 @@ "keywords": [ | ||
"scripts": { | ||
"build:lib": "cross-env BABEL_ENV=commonjs babel src --out-dir lib --ignore **/__tests__", | ||
"build:es": "babel src --out-dir es --ignore **/__tests__", | ||
"build:lib": "cross-env BABEL_ENV=commonjs babel src --out-dir lib --ignore **/*.test.js", | ||
"build:es": "babel src --out-dir es --ignore **/*.test.js", | ||
"build": "npm run build:lib && npm run build:es", | ||
@@ -69,2 +69,3 @@ "clean": "rimraf lib es", | ||
"jest": "^24.9.0", | ||
"jest-localstorage-mock": "^2.4.8", | ||
"react": "^16.14.0", | ||
@@ -77,2 +78,6 @@ "react-dom": "^16.14.0", | ||
"jest": { | ||
"resetMocks": false, | ||
"setupFiles": [ | ||
"jest-localstorage-mock" | ||
], | ||
"setupFilesAfterEnv": [ | ||
@@ -79,0 +84,0 @@ "<rootDir>/test-setup.js" |
@@ -42,3 +42,3 @@ # <img src="https://simpler-state.js.org/assets/simpler-state-logo.png" alt="SimpleR State" width="240"/> | ||
counter.set(value => value + by) | ||
// Alternatively: counter.set(counter.get() + by) | ||
// --OR--> counter.set(counter.get() + by) | ||
} | ||
@@ -54,2 +54,3 @@ ``` | ||
const count = counter.use() | ||
// --OR--> const count = useEntity(counter) | ||
@@ -56,0 +57,0 @@ return ( |
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
29727
604
81
29