01 · Before and afterThe pattern
setScope(ws: string, route: string) {
if (ws === this.ws && route === this.route) return;
this.ws = ws; this.route = route;
this.models.value = []; this.modelId.value = undefined; // before: kept until load() resolved
const req = ++this.requestId;
this.load(ws, route).then(r => { if (req === this.requestId) this.models.value = r; });
}02 · Run it on your appThe check
If a user switches workspace and acts before the new data arrives, can your app submit a value from the old workspace?
If the honest answer is no or not sure, this is worth a look before it reaches production.