diff options
Diffstat (limited to 'frontend/ts/src/lib')
| -rw-r--r-- | frontend/ts/src/lib/leaflet.d.ts | 6 | ||||
| -rw-r--r-- | frontend/ts/src/lib/rx.ts | 18 |
2 files changed, 20 insertions, 4 deletions
diff --git a/frontend/ts/src/lib/leaflet.d.ts b/frontend/ts/src/lib/leaflet.d.ts index 76b88fd..ab8b038 100644 --- a/frontend/ts/src/lib/leaflet.d.ts +++ b/frontend/ts/src/lib/leaflet.d.ts @@ -40,6 +40,12 @@ export interface Layer { addEventListener: (name: string, fn: (e: MapEvent) => void) => void getLatLng: () => Pos setLatLng: (pos: Pos) => void + dragging: Dragging +} + +export interface Dragging { + enable(): () => void + disable(): () => void } export function tileLayer(url: string): Layer 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, |
