diff options
Diffstat (limited to 'frontend/ts/src/lib')
| -rw-r--r-- | frontend/ts/src/lib/rx.ts | 18 | 
1 files changed, 14 insertions, 4 deletions
| diff --git a/frontend/ts/src/lib/rx.ts b/frontend/ts/src/lib/rx.ts index 5edd3c1..b532842 100644 --- a/frontend/ts/src/lib/rx.ts +++ b/frontend/ts/src/lib/rx.ts @@ -1,4 +1,4 @@ -// Rx 3.0.0 +// Rx 3.1.0  // Html @@ -266,16 +266,22 @@ export function pure<A>(value: A): Rx<A> {    return new Pure(value)  } -class Var<A> extends Rx<A> { +export class Var<A> extends Rx<A> {    readonly type: 'Var'    readonly id: string    readonly update: (f: (value: A) => A) => void +  readonly now: () => A -  constructor(id: string, update: (v: Var<A>) => ((f: ((value: A) => A)) => void)) { +  constructor( +      id: string, +      update: (v: Var<A>) => ((f: ((value: A) => A)) => void), +      now: (v: Var<A>) => (() => A) +  ) {      super()      this.id = id      this.type = 'Var'      this.update = update(this) +    this.now = now(this)    }  } @@ -350,7 +356,11 @@ class State {    }    register<A>(initValue: A) { -    const v = new Var(this.varCounter.toString(), v => (f => this.update(v, f))) +    const v = new Var( +        this.varCounter.toString(), +        v => (f => this.update(v, f)), +        v => () => this.get(v) +    )      this.varCounter += BigInt(1)      this.state[v.id] = {        value: initValue, | 
