Add missing "error" event to `on` and `off` type definitions
This commit is contained in:
parent
c37d10bb9d
commit
cc2250da1f
10
relay.ts
10
relay.ts
|
@ -3,6 +3,8 @@
|
|||
import {Event, verifySignature, validateEvent} from './event'
|
||||
import {Filter, matchFilters} from './filter'
|
||||
|
||||
type RelayEvent = 'connect' | 'disconnect' | 'error' | 'notice'
|
||||
|
||||
export type Relay = {
|
||||
url: string
|
||||
status: number
|
||||
|
@ -10,8 +12,8 @@ export type Relay = {
|
|||
close: () => Promise<void>
|
||||
sub: (filters: Filter[], opts: SubscriptionOptions) => Sub
|
||||
publish: (event: Event) => Pub
|
||||
on: (type: 'connect' | 'disconnect' | 'notice', cb: any) => void
|
||||
off: (type: 'connect' | 'disconnect' | 'notice', cb: any) => void
|
||||
on: (type: RelayEvent, cb: any) => void
|
||||
off: (type: RelayEvent, cb: any) => void
|
||||
}
|
||||
export type Pub = {
|
||||
on: (type: 'ok' | 'seen' | 'failed', cb: any) => void
|
||||
|
@ -185,7 +187,7 @@ export function relayInit(url: string): Relay {
|
|||
url,
|
||||
sub,
|
||||
on: (
|
||||
type: 'connect' | 'disconnect' | 'error' | 'notice',
|
||||
type: RelayEvent,
|
||||
cb: any
|
||||
): void => {
|
||||
listeners[type].push(cb)
|
||||
|
@ -194,7 +196,7 @@ export function relayInit(url: string): Relay {
|
|||
}
|
||||
},
|
||||
off: (
|
||||
type: 'connect' | 'disconnect' | 'error' | 'notice',
|
||||
type: RelayEvent,
|
||||
cb: any
|
||||
): void => {
|
||||
let index = listeners[type].indexOf(cb)
|
||||
|
|
Loading…
Reference in New Issue