diff --git a/src/Logic/UIEventSource.ts b/src/Logic/UIEventSource.ts index 43f40558f..1652681a1 100644 --- a/src/Logic/UIEventSource.ts +++ b/src/Logic/UIEventSource.ts @@ -1,6 +1,5 @@ import { Utils } from "../Utils" import { Readable, Subscriber, Unsubscriber, Updater, Writable } from "svelte/store" - /** * Various static utils */ @@ -952,15 +951,14 @@ export class UIEventSource extends Store implements Writable { g: (j: J, t: T) => T, allowUnregister = false ): UIEventSource { - const self = this const stack = new Error().stack.split("\n") const callee = stack[1] const newSource = new UIEventSource(f(this.data), "map(" + this.tag + ")@" + callee) - const update = function () { - newSource.setData(f(self.data)) + const update =() => { + newSource.setData(f(this.data)) return allowUnregister && newSource._callbacks.length() === 0 } @@ -971,7 +969,7 @@ export class UIEventSource extends Store implements Writable { if (g !== undefined) { newSource.addCallback((latest) => { - self.setData(g(latest, self.data)) + this.setData(g(latest, this.data)) }) } @@ -980,8 +978,7 @@ export class UIEventSource extends Store implements Writable { public syncWith(otherSource: UIEventSource, reverseOverride = false): UIEventSource { this.addCallback((latest) => otherSource.setData(latest)) - const self = this - otherSource.addCallback((latest) => self.setData(latest)) + otherSource.addCallback((latest) => this.setData(latest)) if (reverseOverride) { if (otherSource.data !== undefined) { this.setData(otherSource.data)