theatre/packages/dataverse/src/derivations/ConstantDerivation.ts
2022-02-23 22:53:39 +01:00

29 lines
473 B
TypeScript

import AbstractDerivation from './AbstractDerivation'
/**
* A derivation whose value never changes.
*/
export default class ConstantDerivation<V> extends AbstractDerivation<V> {
private readonly _v: V
/**
* @param v - The value of the derivation.
*/
constructor(v: V) {
super()
this._v = v
return this
}
/**
* @internal
*/
_recalculate() {
return this._v
}
/**
* @internal
*/
_reactToDependencyBecomingStale() {}
}