From f5799562a4b054678ad98837a470fa7a89f869b9 Mon Sep 17 00:00:00 2001 From: Codain Date: Tue, 7 Jun 2022 22:27:12 +0200 Subject: [PATCH 1/3] Etymology - Add new French prefixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Place, Villa, Impasse, Route, Résidence + 'de' after all prefixes --- assets/layers/etymology/etymology.json | 53 +++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 6 deletions(-) diff --git a/assets/layers/etymology/etymology.json b/assets/layers/etymology/etymology.json index 63268951d..804da649d 100644 --- a/assets/layers/etymology/etymology.json +++ b/assets/layers/etymology/etymology.json @@ -58,58 +58,99 @@ "Q22698" ], "removePrefixes": [ + "allée de", "allée du", "allée", + "autoroute de", "autoroute du", "autoroute", + "avenue de", "avenue du", "avenue", + "bibliothèque de", "bibliothèque du", "bibliothèque", + "boulevard de", "boulevard du", "boulevard", - "centre du", - "centre", + "centre culturel de", "centre culturel du", "centre culturel", + "centre de", + "centre du", + "centre", + "chaussée de", "chaussée du", "chaussée", + "chemin de", "chemin du", "chemin", + "collège de", "collège du", "collège", + "complexe sportif de", "complexe sportif du", "complexe sportif", - "école du", - "école", + "école élémentaire de", "école élémentaire du", "école élémentaire", + "école maternelle de", "école maternelle du", "école maternelle", + "école primaire de", "école primaire du", "école primaire", + "école de", + "école du", + "école", + "esplanade de", "esplanade du", "esplanade", + "groupe scolaire de", "groupe scolaire du", "groupe scolaire", + "gymnase de", "gymnase du", "gymnase", + "impasse de", + "impasse du", + "impasse", + "lycée de", "lycée du", "lycée", + "mail de", "mail du", "mail", + "médiathèque de", "médiathèque du", "médiathèque", + "musée de", "musée du", "musée", + "parc de", "parc du", "parc", + "place de", + "place du", + "place", + "résidence de", + "résidence du", + "résidence", + "route de", + "route du", + "route", + "rue de", "rue du", "rue", + "square de", "square du", "square", + "stade de", "stade du", - "stade" + "stade", + "villa de", + "villa du", + "villa" ], "removePostfixes": [ "baan", @@ -278,4 +319,4 @@ } } ] -} \ No newline at end of file +} From f97b770203b25c37bda6bd31c5d6618d7a63076d Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Wed, 8 Jun 2022 01:20:37 +0200 Subject: [PATCH 2/3] More debugging of mappedStore --- Logic/UIEventSource.ts | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/Logic/UIEventSource.ts b/Logic/UIEventSource.ts index eadd38d52..9a0044b98 100644 --- a/Logic/UIEventSource.ts +++ b/Logic/UIEventSource.ts @@ -305,7 +305,8 @@ export class ImmutableStore extends Store { */ class ListenerTracker { private readonly _callbacks: ((t: T) => (boolean | void | any)) [] = []; - + + public pingCount = 0; /** * Adds a callback which can be called; a function to unregister is returned */ @@ -330,6 +331,7 @@ class ListenerTracker { * Returns the number of registered callbacks */ public ping(data: T): number { + this.pingCount ++; let toDelete = undefined let startTime = new Date().getTime() / 1000; for (const callback of this._callbacks) { @@ -368,6 +370,8 @@ class ListenerTracker { class MappedStore extends Store { private _upstream: Store; + private _upstreamCallbackHandler: ListenerTracker; + private _upstreamPingCount: number = -1; private _unregisterFromUpstream: (() => void) private _f: (t: TIn) => T; private readonly _extraStores: Store[] | undefined; @@ -378,18 +382,38 @@ class MappedStore extends Store { private static readonly pass: () => {} - constructor(upstream: Store, f: (t: TIn) => T, extraStores: Store[] = undefined, initialData : T= undefined) { + constructor(upstream: Store, f: (t: TIn) => T, extraStores: Store[] = undefined, + upstreamListenerHandler: ListenerTracker) { super(); this._upstream = upstream; + this._upstreamCallbackHandler = upstreamListenerHandler this._f = f; - this._data = initialData ?? f(upstream.data) + this._data = f(upstream.data) + this._upstreamPingCount = upstreamListenerHandler.pingCount this._extraStores = extraStores; } private _data: T; private _callbacksAreRegistered = false - get data(): T { + /** + * Gets the current data from the store + * + * const src = new UIEventSource(21) + * const mapped = src.map(i => i * 2) + * src.setData(3) + * mapped.data // => 6 + * + */ + get data(): T { + if (!this._callbacksAreRegistered) { + // Callbacks are not registered, so we haven't been listening for updates from the upstream which might have changed + if(this._upstreamCallbackHandler.pingCount != this._upstreamPingCount){ + // Upstream has pinged - let's update our data first + this._data = this._f(this._upstream.data) + } + return this._data + } return this._data } @@ -413,7 +437,7 @@ class MappedStore extends Store { this._upstream, data => f(this._f(data)), stores, - f(this._data) + this._upstreamCallbackHandler ); } @@ -426,6 +450,7 @@ class MappedStore extends Store { private update(): void { const newData = this._f(this._upstream.data) + this._upstreamPingCount = this._upstreamCallbackHandler.pingCount if (this._data == newData) { return; } @@ -487,7 +512,7 @@ class MappedStore extends Store { export class UIEventSource extends Store { public data: T; - private _callbacks: ListenerTracker = new ListenerTracker() + _callbacks: ListenerTracker = new ListenerTracker() private static readonly pass: () => {} @@ -637,7 +662,7 @@ export class UIEventSource extends Store { */ public map(f: ((t: T) => J), extraSources: Store[] = []): Store { - return new MappedStore(this, f, extraSources); + return new MappedStore(this, f, extraSources, this._callbacks); } /** From eac33934953b7806610908a7ec83afcc34c32d36 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Wed, 8 Jun 2022 01:39:58 +0200 Subject: [PATCH 3/3] Register callbacks to mapped store immediately too --- Logic/UIEventSource.ts | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/Logic/UIEventSource.ts b/Logic/UIEventSource.ts index 9a0044b98..5fbfdcda6 100644 --- a/Logic/UIEventSource.ts +++ b/Logic/UIEventSource.ts @@ -373,6 +373,7 @@ class MappedStore extends Store { private _upstreamCallbackHandler: ListenerTracker; private _upstreamPingCount: number = -1; private _unregisterFromUpstream: (() => void) + private _f: (t: TIn) => T; private readonly _extraStores: Store[] | undefined; private _unregisterFromExtraStores: (() => void)[] | undefined @@ -391,6 +392,7 @@ class MappedStore extends Store { this._data = f(upstream.data) this._upstreamPingCount = upstreamListenerHandler.pingCount this._extraStores = extraStores; + this.registerCallbacksToUpstream() } private _data: T; @@ -447,6 +449,18 @@ class MappedStore extends Store { this._unregisterFromUpstream() this._unregisterFromExtraStores?.forEach(unr => unr()) } + + private registerCallbacksToUpstream() { + const self = this + + this._unregisterFromUpstream = this._upstream.addCallback( + _ => self.update() + ) + this._unregisterFromExtraStores = this._extraStores?.map(store => + store?.addCallback(_ => self.update()) + ) + this._callbacksAreRegistered = true; + } private update(): void { const newData = this._f(this._upstream.data) @@ -460,16 +474,9 @@ class MappedStore extends Store { addCallback(callback: (data: T) => (any | boolean | void)): (() => void) { if (!this._callbacksAreRegistered) { - const self = this // This is the first callback that is added // We register this 'map' to the upstream object and all the streams - this._unregisterFromUpstream = this._upstream.addCallback( - _ => self.update() - ) - this._unregisterFromExtraStores = this._extraStores?.map(store => - store?.addCallback(_ => self.update()) - ) - this._callbacksAreRegistered = true; + this.registerCallbacksToUpstream() } const unregister = this._callbacks.addCallback(callback) return () => {