From 27b9c96afd2714f17a22f64e593f8f4a7b6b0e71 Mon Sep 17 00:00:00 2001 From: Aria Minaei Date: Thu, 1 Dec 2022 14:44:38 +0100 Subject: [PATCH] Unify Derivation and Prism 8/n --- packages/react/src/index.ts | 4 ++-- theatre/core/src/sequences/Sequence.ts | 12 ++++++------ theatre/core/src/sheetObjects/SheetObject.ts | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/react/src/index.ts b/packages/react/src/index.ts index 3e5c5df..ba94e5f 100644 --- a/packages/react/src/index.ts +++ b/packages/react/src/index.ts @@ -41,7 +41,7 @@ function useForceUpdate(debugLabel?: string) { /** * A React hook that executes the callback function and returns its return value * whenever there's a change in the values of the dependency array, or in the - * derivations that are used within the callback function. + * prisms that are used within the callback function. * * @param fn - The callback function * @param deps - The dependency array @@ -285,7 +285,7 @@ function queueIfNeeded() { * * ```ts * const num = new Box(1) - * const isPositiveD = prism(() => num.derivation.getValue() >= 0) + * const isPositiveD = prism(() => num.prism.getValue() >= 0) * * const Comp = () => { * return
{useDerivation(isPositiveD)}
diff --git a/theatre/core/src/sequences/Sequence.ts b/theatre/core/src/sequences/Sequence.ts index b19355b..487fd2d 100644 --- a/theatre/core/src/sequences/Sequence.ts +++ b/theatre/core/src/sequences/Sequence.ts @@ -38,7 +38,7 @@ export default class Sequence { publicApi: TheatreSequence private _playbackControllerBox: IBox - private _statePointerDerivation: Prism> + private _prismOfStatePointer: Prism> private _positionD: Prism private _positionFormatterD: Prism _playableRangeD: undefined | Prism<{start: number; end: number}> @@ -66,12 +66,12 @@ export default class Sequence { playbackController ?? new DefaultPlaybackController(getCoreTicker()), ) - this._statePointerDerivation = prism( + this._prismOfStatePointer = prism( () => this._playbackControllerBox.prism.getValue().statePointer, ) this._positionD = prism(() => { - const statePointer = this._statePointerDerivation.getValue() + const statePointer = this._prismOfStatePointer.getValue() return val(statePointer.position) }) @@ -99,7 +99,7 @@ export default class Sequence { return this._positionD } else if (prop === 'playing') { return prism(() => { - return val(this._statePointerDerivation.getValue().playing) + return val(this._prismOfStatePointer.getValue().playing) }) } else { return prism(() => undefined) @@ -110,8 +110,8 @@ export default class Sequence { return this._positionFormatterD.getValue() } - get derivationToStatePointer() { - return this._statePointerDerivation + get prismOfStatePointer() { + return this._prismOfStatePointer } get length() { diff --git a/theatre/core/src/sheetObjects/SheetObject.ts b/theatre/core/src/sheetObjects/SheetObject.ts index e0dfce1..d927f09 100644 --- a/theatre/core/src/sheetObjects/SheetObject.ts +++ b/theatre/core/src/sheetObjects/SheetObject.ts @@ -85,7 +85,7 @@ export default class SheetObject implements IdentityPrismProvider { * if boo.bar.baz is sequenced and the sequence is playing, this prism will recalculate on every frame. * This might sound inefficient, but we have a few tricks to make it fast: * - * First, on each recalculation, most of the derivations that this prism depends on will not have changed, + * First, on each recalculation, most of the prisms that this prism depends on will not have changed, * and so reading them is cheap. For example, if foo.bar.baz changed due to being sequenced, but * foo.bar2 hasn't because it is static, reading foo.bar2 will be cheap. *