Make executor.publish's signature more permissive
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "paravel",
|
"name": "paravel",
|
||||||
"version": "0.4.10",
|
"version": "0.4.11",
|
||||||
"description": "Yet another toolkit for nostr",
|
"description": "Yet another toolkit for nostr",
|
||||||
"author": "hodlbod",
|
"author": "hodlbod",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
+4
-4
@@ -15,7 +15,7 @@ type AuthCallback = (url: string, challenge: string) => void
|
|||||||
type OkCallback = (url: string, id: string, ...extra: any[]) => void
|
type OkCallback = (url: string, id: string, ...extra: any[]) => void
|
||||||
type ErrorCallback = (url: string, id: string, ...extra: any[]) => void
|
type ErrorCallback = (url: string, id: string, ...extra: any[]) => void
|
||||||
type SubscribeOpts = {onEvent?: EventCallback, onEose?: EoseCallback}
|
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}
|
type AuthOpts = {onAuth: AuthCallback, onOk: OkCallback}
|
||||||
|
|
||||||
const createSubId = (prefix: string) => [prefix, Math.random().toString().slice(2, 10)].join('-')
|
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) {
|
publish(event: Event, {verb = 'EVENT', onOk, onError}: PublishOpts = {}) {
|
||||||
const okListener = (url: string, id: string, ...payload: any[]) => id === event.id && onOk(url, id, ...payload)
|
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)
|
const errorListener = (url: string, id: string, ...payload: any[]) => id === event.id && onError?.(url, id, ...payload)
|
||||||
|
|
||||||
this.target.on('OK', okListener)
|
this.target.on('OK', okListener)
|
||||||
this.target.on('ERROR', errorListener)
|
this.target.on('ERROR', errorListener)
|
||||||
|
|||||||
Reference in New Issue
Block a user