From a71fff0c73f2ea632e6f4699ae46b9b6600bfeed Mon Sep 17 00:00:00 2001 From: Aria Minaei Date: Sun, 27 Nov 2022 12:58:56 +0100 Subject: [PATCH] Don't expose PrismDerivation as a class --- packages/dataverse/src/derivations/prism/prism.test.ts | 4 ++-- packages/dataverse/src/derivations/prism/prism.ts | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/dataverse/src/derivations/prism/prism.test.ts b/packages/dataverse/src/derivations/prism/prism.test.ts index ac30adb..27717eb 100644 --- a/packages/dataverse/src/derivations/prism/prism.test.ts +++ b/packages/dataverse/src/derivations/prism/prism.test.ts @@ -5,7 +5,7 @@ import Atom, {val} from '../../Atom' import Ticker from '../../Ticker' import type {$FixMe, $IntentionalAny} from '../../types' import iterateAndCountTicks from '../iterateAndCountTicks' -import prism, {PrismDerivation} from './prism' +import prism from './prism' describe('prism', () => { let ticker: Ticker @@ -15,7 +15,7 @@ describe('prism', () => { it('should work', () => { const o = new Atom({foo: 'foo'}) - const d = new PrismDerivation(() => { + const d = prism(() => { return val(o.pointer.foo) + 'boo' }) expect(d.getValue()).toEqual('fooboo') diff --git a/packages/dataverse/src/derivations/prism/prism.ts b/packages/dataverse/src/derivations/prism/prism.ts index eb4c5d6..687daa8 100644 --- a/packages/dataverse/src/derivations/prism/prism.ts +++ b/packages/dataverse/src/derivations/prism/prism.ts @@ -20,7 +20,7 @@ type IDependent = (msgComingFrom: IDerivation<$IntentionalAny>) => void const voidFn = () => {} -export class PrismDerivation implements IDerivation { +class PrismDerivation implements IDerivation { protected _cacheOfDendencyValues: Map, unknown> = new Map() protected _possiblyStaleDeps = new Set>() @@ -123,7 +123,6 @@ export class PrismDerivation implements IDerivation { * * @see removeDependent */ - // TODO: document this better, what are dependents? addDependent(d: IDependent) { const hadDepsBefore = this._dependents.size > 0 this._dependents.add(d)