diff options
Diffstat (limited to 'src/rx.ts')
-rw-r--r-- | src/rx.ts | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -270,12 +270,18 @@ 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, |