diff --git a/src/index.ts b/src/index.ts index d7350ee..e00a0fb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,6 +6,8 @@ import b4a from "b4a"; const ID = b4a.from("lumeweb"); export default class RPC extends ProtomuxRPC { + private _ready: Promise; + constructor(stream: any, options = {}) { options = { ...{ @@ -15,9 +17,17 @@ export default class RPC extends ProtomuxRPC { ...options, }; super(stream, options); + this._ready = new Promise((resolve) => { + // @ts-ignore + this.on("open", resolve); + }); } async request(method: any, value: any | string = "", options = {}) { return super.request(method, value, options); } + + get ready(): Promise { + return this._ready; + } }