Don't expose PrismDerivation as a class
This commit is contained in:
parent
e0a61981c9
commit
a71fff0c73
2 changed files with 3 additions and 4 deletions
|
@ -5,7 +5,7 @@ import Atom, {val} from '../../Atom'
|
||||||
import Ticker from '../../Ticker'
|
import Ticker from '../../Ticker'
|
||||||
import type {$FixMe, $IntentionalAny} from '../../types'
|
import type {$FixMe, $IntentionalAny} from '../../types'
|
||||||
import iterateAndCountTicks from '../iterateAndCountTicks'
|
import iterateAndCountTicks from '../iterateAndCountTicks'
|
||||||
import prism, {PrismDerivation} from './prism'
|
import prism from './prism'
|
||||||
|
|
||||||
describe('prism', () => {
|
describe('prism', () => {
|
||||||
let ticker: Ticker
|
let ticker: Ticker
|
||||||
|
@ -15,7 +15,7 @@ describe('prism', () => {
|
||||||
|
|
||||||
it('should work', () => {
|
it('should work', () => {
|
||||||
const o = new Atom({foo: 'foo'})
|
const o = new Atom({foo: 'foo'})
|
||||||
const d = new PrismDerivation(() => {
|
const d = prism(() => {
|
||||||
return val(o.pointer.foo) + 'boo'
|
return val(o.pointer.foo) + 'boo'
|
||||||
})
|
})
|
||||||
expect(d.getValue()).toEqual('fooboo')
|
expect(d.getValue()).toEqual('fooboo')
|
||||||
|
|
|
@ -20,7 +20,7 @@ type IDependent = (msgComingFrom: IDerivation<$IntentionalAny>) => void
|
||||||
|
|
||||||
const voidFn = () => {}
|
const voidFn = () => {}
|
||||||
|
|
||||||
export class PrismDerivation<V> implements IDerivation<V> {
|
class PrismDerivation<V> implements IDerivation<V> {
|
||||||
protected _cacheOfDendencyValues: Map<IDerivation<unknown>, unknown> =
|
protected _cacheOfDendencyValues: Map<IDerivation<unknown>, unknown> =
|
||||||
new Map()
|
new Map()
|
||||||
protected _possiblyStaleDeps = new Set<IDerivation<unknown>>()
|
protected _possiblyStaleDeps = new Set<IDerivation<unknown>>()
|
||||||
|
@ -123,7 +123,6 @@ export class PrismDerivation<V> implements IDerivation<V> {
|
||||||
*
|
*
|
||||||
* @see removeDependent
|
* @see removeDependent
|
||||||
*/
|
*/
|
||||||
// TODO: document this better, what are dependents?
|
|
||||||
addDependent(d: IDependent) {
|
addDependent(d: IDependent) {
|
||||||
const hadDepsBefore = this._dependents.size > 0
|
const hadDepsBefore = this._dependents.size > 0
|
||||||
this._dependents.add(d)
|
this._dependents.add(d)
|
||||||
|
|
Loading…
Reference in a new issue