From 376a2d330cd7b5da0e8f74160d13e78e623823c4 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Wed, 1 Feb 2023 07:42:16 -0500 Subject: [PATCH] *Have client extend event emitter --- package.json | 1 + pnpm-lock.yaml | 6 ++++++ src/index.ts | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 9479db8..0ba17d4 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ }, "dependencies": { "@siaweb/libweb": "git+https://git.lumeweb.com/LumeWeb/libsiaweb.git", + "eventemitter2": "^6.4.9", "libkernel": "^0.1.48", "libkmodule": "^0.2.53" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d0dcff0..7436204 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2,6 +2,7 @@ lockfileVersion: 5.4 specifiers: '@siaweb/libweb': git+https://git.lumeweb.com/LumeWeb/libsiaweb.git + eventemitter2: ^6.4.9 libkernel: ^0.1.48 libkmodule: ^0.2.53 prettier: ^2.8.3 @@ -9,6 +10,7 @@ specifiers: dependencies: '@siaweb/libweb': git.lumeweb.com/LumeWeb/libsiaweb/5e6cdba3e7d9a4b94e21ddcd5f2b5138fb440ee8 + eventemitter2: 6.4.9 libkernel: 0.1.48 libkmodule: 0.2.53 @@ -22,6 +24,10 @@ packages: resolution: {integrity: sha512-wFqPLVuGyfuEU1PsE7AMC+ANcoJiz7iruJPUrNZC0riDv1qMrZw+tx44HlBXLJ1H50JZiGtRPr9zLgkPFhf9OA==} dev: false + /eventemitter2/6.4.9: + resolution: {integrity: sha512-JEPTiaOt9f04oa6NOkc4aH+nVp5I3wEjpHbIPqfgCdD5v5bUzy7xQqwcVO2aDQgOWhI28da57HksMrzK9HlRxg==} + dev: false + /libkernel/0.1.48: resolution: {integrity: sha512-h86j/D+5gnpw/h8DTQE1C9hWFRmQnw5ZU9L3fYTZIPqPEIIU40z+tnDp66Zbb6mcfYCr8+SGkhcCy3XsyHOvyQ==} dependencies: diff --git a/src/index.ts b/src/index.ts index 3d42f2f..be976f6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,6 +4,7 @@ type logErr = typeof import("libkmodule").logErr; type log = typeof import("libkmodule").log; import type { ErrTuple, DataFn } from "@siaweb/libweb"; +import { EventEmitter2 as EventEmitter } from "eventemitter2"; type callModuleBound = (method: string, data?: any) => Promise; type connectModuleBound = ( @@ -29,7 +30,7 @@ export interface ModuleBagBound extends ModuleBag { connectModule: connectModuleBound; } -export abstract class Client { +export abstract class Client extends EventEmitter { private _callModule?: callModuleBound; get callModule(): callModuleBound {