Note down that map/flatMap must be removed
This commit is contained in:
parent
6d7d461223
commit
83832ef85b
3 changed files with 4 additions and 0 deletions
|
@ -256,6 +256,7 @@ export default abstract class AbstractDerivation<V> implements IDerivation<V> {
|
||||||
* @deprecated This is a remnant of the old monadic api. Now it's functionally equal to `prism(() => fn(der.getValue()))`, so use that instead.
|
* @deprecated This is a remnant of the old monadic api. Now it's functionally equal to `prism(() => fn(der.getValue()))`, so use that instead.
|
||||||
*/
|
*/
|
||||||
map<T>(fn: (v: V) => T): IDerivation<T> {
|
map<T>(fn: (v: V) => T): IDerivation<T> {
|
||||||
|
// TODO once prism and AbstractDerivation are merged into one, we should replace this with prism(() => fn(der.getValue()))
|
||||||
return map(this, fn)
|
return map(this, fn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,6 +280,7 @@ export default abstract class AbstractDerivation<V> implements IDerivation<V> {
|
||||||
flatMap<R>(
|
flatMap<R>(
|
||||||
fn: (v: V) => R,
|
fn: (v: V) => R,
|
||||||
): IDerivation<R extends IDerivation<infer T> ? T : R> {
|
): IDerivation<R extends IDerivation<infer T> ? T : R> {
|
||||||
|
// TODO once prism and AbstractDerivation are merged into one, we should replace this with prism(() => val(fn(val(der))))
|
||||||
return flatMap(this, fn)
|
return flatMap(this, fn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ enum UPDATE_NEEDED_FROM {
|
||||||
}
|
}
|
||||||
|
|
||||||
const makeFlatMapDerivationClass = () => {
|
const makeFlatMapDerivationClass = () => {
|
||||||
|
// TODO once prism and AbstractDerivation are merged into one, we should delete this file
|
||||||
class FlatMapDerivation<V, DepType> extends AbstractDerivation<V> {
|
class FlatMapDerivation<V, DepType> extends AbstractDerivation<V> {
|
||||||
private _innerDerivation: undefined | null | IDerivation<V>
|
private _innerDerivation: undefined | null | IDerivation<V>
|
||||||
private _staleDependency: UPDATE_NEEDED_FROM
|
private _staleDependency: UPDATE_NEEDED_FROM
|
||||||
|
|
|
@ -3,6 +3,7 @@ import type {IDerivation} from './IDerivation'
|
||||||
|
|
||||||
// Exporting from a function because of the circular dependency with AbstractDerivation
|
// Exporting from a function because of the circular dependency with AbstractDerivation
|
||||||
const makeMapDerivationClass = () =>
|
const makeMapDerivationClass = () =>
|
||||||
|
// TODO once prism and AbstractDerivation are merged into one, we should delete this file
|
||||||
class MapDerivation<T, V> extends AbstractDerivation<V> {
|
class MapDerivation<T, V> extends AbstractDerivation<V> {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly _dep: IDerivation<T>,
|
private readonly _dep: IDerivation<T>,
|
||||||
|
|
Loading…
Reference in a new issue