From e759d06faad392765a564dba54b1778963a1b06e Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Wed, 31 Aug 2022 20:14:48 -0400 Subject: [PATCH] *Update dist --- dist/index.d.ts | 2 ++ dist/index.d.ts.map | 2 +- dist/index.js | 22 ++++++++++++++++------ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/dist/index.d.ts b/dist/index.d.ts index 2e1d504..9f12f68 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -71,12 +71,14 @@ export declare class SimpleRpcQuery extends RpcQueryBase { } export declare class StreamingRpcQuery extends SimpleRpcQuery { protected _options: StreamingRpcQueryOptions; + private _sendUpdate?; constructor( network: RpcNetwork, relay: string | Buffer, query: RPCRequest, options: StreamingRpcQueryOptions ); + cancel(): void; run(): this; get result(): Promise; } diff --git a/dist/index.d.ts.map b/dist/index.d.ts.map index b58778d..c1d2592 100644 --- a/dist/index.d.ts.map +++ b/dist/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAuBhC,qBAAa,UAAU;IACrB,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,IAAI,CAAU;gBAEV,GAAG,GAAE,OAAc;IAI/B,OAAO,CAAC,UAAU,CAAa;IAE/B,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,KAAK,IAAI,OAAO,CAAC,QAAQ,CAAC,CAc7B;IAED,OAAO,CAAC,MAAM,C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AEhC,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,eAAe;IAKnB,GAAG,IAAI,IAAI;CAYnB;AAED,qBAAa,iBAAkB,SAAQ,cAAc;IACnD,SAAS,CAAC,QAAQ,EAAE,wBAAwB,CAAC;IAC7C,OAAO,CAAC,WAAW,CAAC,CAAS;gBAG3B,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,wBAAwB;IAO5B,MAAM;IAMN,GAAG,IAAI,IAAI;IAoBlB,IAAI,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,CAWjC;CACF;AAED,qBAAa,cAAe,SAAQ,YAAY;gBAE5C,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,UAAU,EACjB,OAAO,GAAE,eAAoB;CAIhC"} \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index 9a0890c..aae1dbf 100644 --- a/dist/index.js +++ b/dist/index.js @@ -148,18 +148,28 @@ export class SimpleRpcQuery extends RpcQueryBase { } export class StreamingRpcQuery extends SimpleRpcQuery { _options; + _sendUpdate; constructor(network, relay, query, options) { super(network, relay, query, options); this._options = options; this._queryType = "streamingQuery"; } + cancel() { + if (this._sendUpdate) { + this._sendUpdate({ cancel: true }); + } + } run() { - this._promise = this._network.processQueue().then(() => connectModule(RPC_MODULE, this._queryType, { - relay: this._relay, - query: this._query, - options: { ...this._options, streamHandler: true }, - network: this._network.networkId, - }, this._options.streamHandler)); + this._promise = this._network.processQueue().then(() => { + const ret = connectModule(RPC_MODULE, this._queryType, { + relay: this._relay, + query: this._query, + options: { ...this._options, streamHandler: true }, + network: this._network.networkId, + }, this._options.streamHandler); + this._sendUpdate = ret[0]; + return ret[1]; + }); return this; } get result() {