diff --git a/packages/dataverse/src/derivations/IDerivation.ts b/packages/dataverse/src/derivations/IDerivation.ts index a89d75f..3b37ac0 100644 --- a/packages/dataverse/src/derivations/IDerivation.ts +++ b/packages/dataverse/src/derivations/IDerivation.ts @@ -38,18 +38,21 @@ export interface IDerivation { * * @param d - The derivation to be made a dependent of this derivation. * - * @see removeDependent + * @see _removeDependent + * + * @internal */ - addDependent(d: IDependent): void + _addDependent(d: IDependent): void /** * Remove a derivation as a dependent of this derivation. * * @param d - The derivation to be removed from as a dependent of this derivation. * - * @see addDependent + * @see _addDependent + * @internal */ - removeDependent(d: IDependent): void + _removeDependent(d: IDependent): void /** * Gets the current value of the derivation. If the value is stale, it causes the derivation to freshen. diff --git a/packages/dataverse/src/derivations/prism/prism.ts b/packages/dataverse/src/derivations/prism/prism.ts index 69b973a..25649fa 100644 --- a/packages/dataverse/src/derivations/prism/prism.ts +++ b/packages/dataverse/src/derivations/prism/prism.ts @@ -55,7 +55,7 @@ class HotHandle { private readonly _prismInstance: PrismDerivation, ) { for (const d of this._dependencies) { - d.addDependent(this._reactToDependencyGoingStale) + d._addDependent(this._reactToDependencyGoingStale) } startIgnoringDependencies() @@ -75,7 +75,7 @@ class HotHandle { destroy() { for (const d of this._dependencies) { - d.removeDependent(this._reactToDependencyGoingStale) + d._removeDependent(this._reactToDependencyGoingStale) } cleanupScopeStack(this._scope) } @@ -186,7 +186,7 @@ class HotHandle { protected _addDependency(d: IDerivation<$IntentionalAny>) { if (this._dependencies.has(d)) return this._dependencies.add(d) - d.addDependent(this._reactToDependencyGoingStale) + d._addDependent(this._reactToDependencyGoingStale) } /** @@ -195,7 +195,7 @@ class HotHandle { protected _removeDependency(d: IDerivation<$IntentionalAny>) { if (!this._dependencies.has(d)) return this._dependencies.delete(d) - d.removeDependent(this._reactToDependencyGoingStale) + d._removeDependent(this._reactToDependencyGoingStale) } } @@ -242,7 +242,7 @@ class PrismDerivation implements IDerivation { listener(newValue) } - this.addDependent(dependent) + this._addDependent(dependent) if (immediate) { lastValue = this.getValue() @@ -250,7 +250,7 @@ class PrismDerivation implements IDerivation { } const unsubscribe = () => { - this.removeDependent(dependent) + this._removeDependent(dependent) } return unsubscribe @@ -261,10 +261,10 @@ class PrismDerivation implements IDerivation { */ onStale(callback: () => void): VoidFn { const untap = () => { - this.removeDependent(fn) + this._removeDependent(fn) } const fn = () => callback() - this.addDependent(fn) + this._addDependent(fn) return untap } @@ -280,9 +280,9 @@ class PrismDerivation implements IDerivation { * * @param d - The derivation to be made a dependent of this derivation. * - * @see removeDependent + * @see _removeDependent */ - addDependent(d: IDependent) { + _addDependent(d: IDependent) { if (!this._state.hot) { this._goHot() } @@ -302,9 +302,9 @@ class PrismDerivation implements IDerivation { * * @param d - The derivation to be removed from as a dependent of this derivation. * - * @see addDependent + * @see _addDependent */ - removeDependent(d: IDependent) { + _removeDependent(d: IDependent) { const state = this._state if (!state.hot) { return