Make executor.publish's signature more permissive

This commit is contained in:
Jon Staab
2023-12-01 10:04:07 -08:00
parent 8d6839f9e4
commit 2b901f1ba2
2 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "paravel",
"version": "0.4.10",
"version": "0.4.11",
"description": "Yet another toolkit for nostr",
"author": "hodlbod",
"license": "MIT",
+4 -4
View File
@@ -15,7 +15,7 @@ type AuthCallback = (url: string, challenge: string) => void
type OkCallback = (url: string, id: string, ...extra: any[]) => void
type ErrorCallback = (url: string, id: string, ...extra: any[]) => void
type SubscribeOpts = {onEvent?: EventCallback, onEose?: EoseCallback}
type PublishOpts = {verb: string, onOk: OkCallback, onError: ErrorCallback}
type PublishOpts = {verb?: string, onOk?: OkCallback, onError?: ErrorCallback}
type AuthOpts = {onAuth: AuthCallback, onOk: OkCallback}
const createSubId = (prefix: string) => [prefix, Math.random().toString().slice(2, 10)].join('-')
@@ -48,9 +48,9 @@ export class Executor {
}
}
publish(event: Event, {verb = 'EVENT', onOk, onError}: PublishOpts) {
const okListener = (url: string, id: string, ...payload: any[]) => id === event.id && onOk(url, id, ...payload)
const errorListener = (url: string, id: string, ...payload: any[]) => id === event.id && onError(url, id, ...payload)
publish(event: Event, {verb = 'EVENT', onOk, onError}: PublishOpts = {}) {
const okListener = (url: string, id: string, ...payload: any[]) => id === event.id && onOk?.(url, id, ...payload)
const errorListener = (url: string, id: string, ...payload: any[]) => id === event.id && onError?.(url, id, ...payload)
this.target.on('OK', okListener)
this.target.on('ERROR', errorListener)