*Update StreamingRpcQuery result to handle connectModule properly

This commit is contained in:
Derrick Hammer 2022-08-31 19:15:40 -04:00
parent b3e6290a73
commit 1e3e8f35bc
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 14 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import {
StreamingRpcQueryOptions,
} from "@lumeweb/dht-rpc-client";
import { Buffer } from "buffer";
import { DataFn } from "libskynet/dist";
const RPC_MODULE = "AQDaEPIo_lpdvz7AKbeafERBHR331RiyvweJ6OrFTplzyg";
@ -267,6 +268,19 @@ export class StreamingRpcQuery extends SimpleRpcQuery {
return this;
}
get result(): Promise<RPCResponse> {
return (this._promise as Promise<any>)
.then(
(result): [sendUpdate: DataFn, response: Promise<ErrTuple>] => result[1]
)
.then((response: any) => {
if (response[1]) {
return { error: response[1] };
}
return response[0];
});
}
}
export class WisdomRpcQuery extends RpcQueryBase {