*Add cancel support to streaming query via setReceiveUpdate
This commit is contained in:
parent
b094cb9274
commit
320b5c0a35
|
@ -37,7 +37,7 @@ addHandler("addRelay", handleAddRelay);
|
||||||
addHandler("removeRelay", handleRemoveRelay);
|
addHandler("removeRelay", handleRemoveRelay);
|
||||||
addHandler("clearRelays", handleClearRelays);
|
addHandler("clearRelays", handleClearRelays);
|
||||||
addHandler("simpleQuery", handleSimpleQuery);
|
addHandler("simpleQuery", handleSimpleQuery);
|
||||||
addHandler("streamingQuery", handleStreamingQuery);
|
addHandler("streamingQuery", handleStreamingQuery, { receiveUpdates: true });
|
||||||
addHandler("wisdomQuery", handleWisdomQuery);
|
addHandler("wisdomQuery", handleWisdomQuery);
|
||||||
addHandler("ready", handleReady);
|
addHandler("ready", handleReady);
|
||||||
|
|
||||||
|
@ -175,6 +175,13 @@ async function handleStreamingQuery(aq: ActiveQuery) {
|
||||||
query.data,
|
query.data,
|
||||||
{ ...options }
|
{ ...options }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
aq.setReceiveUpdate?.((message: any) => {
|
||||||
|
if (message && message.cancel) {
|
||||||
|
rpcQuery.cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
resp = await rpcQuery.result;
|
resp = await rpcQuery.result;
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
aq.reject(e);
|
aq.reject(e);
|
||||||
|
|
Loading…
Reference in New Issue