@arcote.tech/arc-react 0.7.15 → 0.7.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +25 -48
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -305,8 +305,7 @@ import {
|
|
|
305
305
|
QueryWire,
|
|
306
306
|
StreamingEventPublisher,
|
|
307
307
|
StreamingQueryCache,
|
|
308
|
-
buildContextAccessor
|
|
309
|
-
resolveQueryChange
|
|
308
|
+
buildContextAccessor
|
|
310
309
|
} from "@arcote.tech/arc";
|
|
311
310
|
import {
|
|
312
311
|
createContext as createContext4,
|
|
@@ -449,8 +448,7 @@ Event payload:`, event.payload);
|
|
|
449
448
|
}
|
|
450
449
|
} else if (eventWire && queryWire) {
|
|
451
450
|
streamingCache = new StreamingQueryCache;
|
|
452
|
-
|
|
453
|
-
eventPublisher = new StreamingEventPublisher(streamingCache, eventWire);
|
|
451
|
+
eventPublisher = new StreamingEventPublisher(eventWire);
|
|
454
452
|
eventPublisher.registerViews(views);
|
|
455
453
|
if (authAdapter.isAuthenticated()) {
|
|
456
454
|
eventWire.connect();
|
|
@@ -516,7 +514,7 @@ Event payload:`, event.payload);
|
|
|
516
514
|
authAdapter.setToken(token, name);
|
|
517
515
|
if (cachedModel) {
|
|
518
516
|
cachedModel.scope(name).setToken(token);
|
|
519
|
-
cachedModel.getAdapters().streamingCache?.invalidateScope(name);
|
|
517
|
+
cachedModel.getAdapters().streamingCache?.invalidateScope(name, eventWire);
|
|
520
518
|
} else {
|
|
521
519
|
eventWire?.setScopeToken(name, token);
|
|
522
520
|
if (eventWire && token && eventWire.getState() === "disconnected") {
|
|
@@ -570,51 +568,30 @@ Event payload:`, event.payload);
|
|
|
570
568
|
return;
|
|
571
569
|
const unsubs = [];
|
|
572
570
|
const element = model.context.get(desc.element);
|
|
573
|
-
const qCtx = element?.queryContext?.(adapters);
|
|
574
|
-
const method = qCtx?.[desc.method];
|
|
575
|
-
const reExecute = async () => {
|
|
576
|
-
if (!method)
|
|
577
|
-
return;
|
|
578
|
-
try {
|
|
579
|
-
const result = await method(...desc.args);
|
|
580
|
-
setData(result);
|
|
581
|
-
setLoading(false);
|
|
582
|
-
} catch (err) {
|
|
583
|
-
console.error(`[Arc] Query error:`, err);
|
|
584
|
-
}
|
|
585
|
-
};
|
|
586
571
|
if (adapters.streamingCache) {
|
|
587
|
-
const
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
current = newResult;
|
|
602
|
-
changed = true;
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
if (!changed)
|
|
606
|
-
return;
|
|
607
|
-
cachedResult = current;
|
|
608
|
-
reExecute();
|
|
572
|
+
const sub = adapters.streamingCache.subscribe(desc, name, adapters.eventWire, () => {
|
|
573
|
+
const snap = sub.read();
|
|
574
|
+
setData(snap.result);
|
|
575
|
+
setLoading(snap.loading);
|
|
576
|
+
});
|
|
577
|
+
unsubs.push(sub.unsubscribe);
|
|
578
|
+
const initial = sub.read();
|
|
579
|
+
setData(initial.result);
|
|
580
|
+
setLoading(initial.loading);
|
|
581
|
+
} else {
|
|
582
|
+
const qCtx = element?.queryContext?.(adapters);
|
|
583
|
+
const method = qCtx?.[desc.method];
|
|
584
|
+
const reExecute = async () => {
|
|
585
|
+
if (!method)
|
|
609
586
|
return;
|
|
587
|
+
try {
|
|
588
|
+
const result = await method(...desc.args);
|
|
589
|
+
setData(result);
|
|
590
|
+
setLoading(false);
|
|
591
|
+
} catch (err) {
|
|
592
|
+
console.error(`[Arc] Query error:`, err);
|
|
610
593
|
}
|
|
611
|
-
|
|
612
|
-
}));
|
|
613
|
-
unsubs.push(adapters.streamingCache.subscribeView(desc.element, adapters.eventWire, name));
|
|
614
|
-
if (store.hasData()) {
|
|
615
|
-
reExecute();
|
|
616
|
-
}
|
|
617
|
-
} else {
|
|
594
|
+
};
|
|
618
595
|
if (adapters.eventPublisher) {
|
|
619
596
|
const aggregateName = element?.name;
|
|
620
597
|
const eventTypes = element?.getElements?.()?.map((e) => aggregateName ? `${aggregateName}.${e.name}` : e.name) ?? [];
|
|
@@ -701,4 +678,4 @@ export {
|
|
|
701
678
|
Form
|
|
702
679
|
};
|
|
703
680
|
|
|
704
|
-
//# debugId=
|
|
681
|
+
//# debugId=966C03CA44E269FA64756E2164756E21
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcote.tech/arc-react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.16",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Przemysław Krasiński [arcote.tech]",
|
|
7
7
|
"description": "React client for the Arc framework, providing utilities for querying data and executing commands, enhancing the development of reactive and efficient user interfaces.",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"typescript": "^5.2.2"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@arcote.tech/arc": "^0.7.
|
|
35
|
+
"@arcote.tech/arc": "^0.7.16",
|
|
36
36
|
"react": "^18.0.0 || ^19.0.0",
|
|
37
37
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
38
38
|
"typescript": "^5.0.0"
|