diff options
Diffstat (limited to 'lang/gjs/src/variable.ts')
-rw-r--r-- | lang/gjs/src/variable.ts | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/lang/gjs/src/variable.ts b/lang/gjs/src/variable.ts index 9b3d3d2..016d73a 100644 --- a/lang/gjs/src/variable.ts +++ b/lang/gjs/src/variable.ts @@ -60,13 +60,11 @@ class VariableWrapper<T> extends Function { if (v instanceof Promise) { v.then(v => this.set(v)) .catch(err => this.variable.emit("error", err)) - } - else { + } else { this.set(v) } }) - } - else if (this.pollExec) { + } else if (this.pollExec) { this._poll = interval(this.pollInterval, () => { execAsync(this.pollExec!) .then(v => this.set(this.pollTransform!(v, this.get()))) @@ -143,8 +141,7 @@ class VariableWrapper<T> extends Function { if (typeof exec === "function") { this.pollFn = exec delete this.pollExec - } - else { + } else { this.pollExec = exec delete this.pollFn } @@ -188,8 +185,7 @@ class VariableWrapper<T> extends Function { const id = o.connect(s, set) this.onDropped(() => o.disconnect(id)) } - } - else { + } else { if (typeof sigOrFn === "string") { const id = objs.connect(sigOrFn, set) this.onDropped(() => objs.disconnect(id)) @@ -227,4 +223,5 @@ export const Variable = new Proxy(VariableWrapper as any, { new<T>(init: T): Variable<T> } +export const { derive } = Variable export default Variable |