Comparing version 0.1.3 to 0.1.4
{ | ||
"name": "fluids", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Glue layer for reactivity", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -9,2 +9,4 @@ # fluids | ||
| ||
## API | ||
@@ -35,2 +37,4 @@ | ||
| ||
## Types | ||
@@ -67,5 +71,7 @@ | ||
| ||
## `FluidConfig` example | ||
This example adds observability to a ref object (like in React: `{ value }`). | ||
This example adds observability to a ref object, like what `React.useRef` returns. | ||
@@ -77,4 +83,4 @@ Any object can conform to the `FluidConfig` interface **without needing to change its public API.** | ||
/** Create a `{ value }` object that can be observed */ | ||
function createRef(value) { | ||
/** Create a ref object that can be observed */ | ||
function createRef(current) { | ||
const ref = {} | ||
@@ -88,13 +94,13 @@ | ||
// Change tracking | ||
const get = () => value | ||
Object.defineProperty(ref, 'value', { | ||
const get = () => current | ||
Object.defineProperty(ref, 'current', { | ||
enumerable: true, | ||
get, | ||
set: newValue => { | ||
if (value !== newValue) { | ||
value = newValue | ||
if (current !== newValue) { | ||
current = newValue | ||
emit({ | ||
type: 'change', | ||
parent: ref, | ||
value, | ||
value: newValue, | ||
}) | ||
@@ -116,2 +122,4 @@ } | ||
| ||
## `FluidObserver` example | ||
@@ -133,5 +141,5 @@ | ||
ref.value++ | ||
ref.current++ | ||
stop() | ||
ref.value++ | ||
ref.current++ | ||
``` |
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
11866
139