proxy-state-tree
Advanced tools
Comparing version 1.0.0-alpha7 to 1.0.0-alpha8
{ | ||
"name": "proxy-state-tree", | ||
"version": "1.0.0-alpha7", | ||
"version": "1.0.0-alpha8", | ||
"description": "An implementation of the Mobx/Vue state tracking approach, for library authors", | ||
@@ -5,0 +5,0 @@ "main": "dist/proxy-state-tree.cjs.js", |
@@ -33,3 +33,3 @@ # proxy-state-tree | ||
You can track access to the state by using the **startPathsTracking** and **stopPathsTracking** methods. | ||
You can track access to the state by using the **startPathsTracking** and **clearPathsTracking** methods. | ||
@@ -45,6 +45,6 @@ ```js | ||
tree.startPathsTracking() | ||
const trackId = tree.startPathsTracking() | ||
const foo = state.foo | ||
const bar = state.bar | ||
const paths = tree.stopPathsTracking() | ||
const paths = tree.clearPathsTracking(trackId) | ||
@@ -54,3 +54,3 @@ console.log(paths) // ['foo', 'bar'] | ||
You would typically use this mechanism to track usage of state. For example rendering a component, calculating a a computed value etc. The returned paths array is stored for later usage. The paths structure is used internally by proxy-state-tree, but you can also consume it as a library author to for example showing components and what paths they depend on in a devtool. Nested paths uses dot notation, for example `['foo.bar']`. | ||
You would typically use this mechanism to track usage of state. For example rendering a component, calculating a a computed value etc. The returned paths array is stored for later usage. The paths structure is used internally by proxy-state-tree, but you can also consume it as a library author to for example showing components and what paths they depend on in a devtool. Nested paths uses dot notation, for example `['foo.bar']`. Path tracking can be nested, but they can not run at the same time. Meaning the nested tracking must finish before the outer tracker. | ||
@@ -71,3 +71,3 @@ ## Track mutations | ||
state.bar.push('baz') | ||
const mutations = tree.stopMutationTracking() | ||
const mutations = tree.clearMutationTracking() | ||
@@ -88,3 +88,3 @@ console.log(mutations) | ||
You would use **startMutationTracking** and **stopMutationTracking** around logic that is allowed to do mutations, for example actions or similar. Trying to mutate without this tracking active results in an error. The returned array can be used in combination with a devtool. | ||
You would use **startMutationTracking** and **clearMutationTracking** around logic that is allowed to do mutations, for example actions or similar. Trying to mutate without this tracking active results in an error. The returned array can be used in combination with a devtool. | ||
@@ -103,7 +103,7 @@ ## Check need to update | ||
function render () { | ||
tree.startPathsTracking() | ||
const trackId = tree.startPathsTracking() | ||
const foo = state.foo | ||
const bar = state.bar | ||
return tree.stopPathsTracking() | ||
return tree.clearPathsTracking(trackId) | ||
} | ||
@@ -123,3 +123,3 @@ | ||
state.bar.push('baz') | ||
tree.stopMutationTracking() | ||
tree.clearMutationTracking() | ||
@@ -134,3 +134,3 @@ // This command flushes out the current mutations and | ||
Here we combine the tracked paths with the mutations performed to see if this components, computed or whatever indeed needs to run again, doing a new **startPathsTracking** and **stopPathsTracking**. | ||
Here we combine the tracked paths with the mutations performed to see if this components, computed or whatever indeed needs to run again, doing a new **startPathsTracking** and **clearPathsTracking**. | ||
@@ -137,0 +137,0 @@ ## Dynamic state values |
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
27600