fluidstate
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -89,12 +89,8 @@ "use strict"; | ||
const createEffect = (calculate, perform) => { | ||
const effectIndicator = {}; | ||
const computed = createComputed(() => { | ||
const computedValue = calculate(); | ||
updateManager.scheduleEffect(effectIndicator, () => perform(computedValue)); | ||
updateManager.callWithoutCollect(() => perform(computedValue)); | ||
return computedValue; | ||
}); | ||
return () => { | ||
dependenciesManager.disableComputed(computed); | ||
updateManager.cancelEffect(effectIndicator); | ||
}; | ||
return () => dependenciesManager.disableComputed(computed); | ||
}; | ||
@@ -101,0 +97,0 @@ return { |
{ | ||
"name": "fluidstate", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Library for fine-grained reactivity state management", | ||
@@ -5,0 +5,0 @@ "repository": "https://gitlab.com/fluidstate/fluidstate", |
@@ -1,1 +0,1 @@ | ||
# Fluid State | ||
# fluidstate |
@@ -9,5 +9,4 @@ import { DependenciesManager } from "./dependencies-manager"; | ||
get: <T_2>(node: Node<T_2>) => T_2; | ||
scheduleEffect: (effectIndicator: object, perform: () => void) => void; | ||
cancelEffect: (effectIndicator: object) => void; | ||
callWithoutCollect: <T_3>(fn: () => T_3) => T_3; | ||
batch: (update: () => void) => void; | ||
}; |
@@ -91,22 +91,2 @@ "use strict"; | ||
}; | ||
let scheduledEffects = new Map(); | ||
const scheduleEffect = (effectIndicator, perform) => { | ||
scheduledEffects.set(effectIndicator, perform); | ||
if (scheduledUpdates.length === 0) { | ||
performAllEffects(); | ||
} | ||
}; | ||
const cancelEffect = effectIndicator => { | ||
scheduledEffects.delete(effectIndicator); | ||
}; | ||
const performAllEffects = () => { | ||
const currentScheduledEffects = scheduledEffects; | ||
scheduledEffects = new Map(); | ||
for (let [, perform] of currentScheduledEffects) { | ||
callWithoutCollect(perform); | ||
} | ||
if (scheduledUpdates.length > 0) { | ||
triggerUpdate(); | ||
} | ||
}; | ||
const triggerUpdate = () => { | ||
@@ -124,3 +104,2 @@ // If we call triggerUpdate() after the update was | ||
if (scheduledUpdates.length === 0) { | ||
performAllEffects(); | ||
return; | ||
@@ -136,3 +115,2 @@ } | ||
cleanupUpdate(); | ||
performAllEffects(); | ||
} | ||
@@ -148,4 +126,3 @@ }; | ||
get, | ||
scheduleEffect, | ||
cancelEffect, | ||
callWithoutCollect, | ||
batch | ||
@@ -152,0 +129,0 @@ }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
191327
1873