2021-06-18 13:05:06 +02:00
|
|
|
import AbstractDerivation from './AbstractDerivation'
|
|
|
|
|
2022-01-19 13:06:13 +01:00
|
|
|
/**
|
|
|
|
* A derivation whose value never changes.
|
|
|
|
*/
|
2021-06-18 13:05:06 +02:00
|
|
|
export default class ConstantDerivation<V> extends AbstractDerivation<V> {
|
2022-01-19 13:06:13 +01:00
|
|
|
private readonly _v: V
|
2021-06-18 13:05:06 +02:00
|
|
|
|
2022-01-19 13:06:13 +01:00
|
|
|
/**
|
2022-02-23 22:53:39 +01:00
|
|
|
* @param v - The value of the derivation.
|
2022-01-19 13:06:13 +01:00
|
|
|
*/
|
2021-06-18 13:05:06 +02:00
|
|
|
constructor(v: V) {
|
|
|
|
super()
|
|
|
|
this._v = v
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
|
2022-01-19 13:06:13 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2021-06-18 13:05:06 +02:00
|
|
|
_recalculate() {
|
|
|
|
return this._v
|
|
|
|
}
|
|
|
|
|
2022-01-19 13:06:13 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2021-06-18 13:05:06 +02:00
|
|
|
_reactToDependencyBecomingStale() {}
|
|
|
|
}
|