SubCloser.close() can take a reason string optionally.
This commit is contained in:
parent
d773012658
commit
12acb900ab
|
@ -12,7 +12,7 @@ import type { Event, EventTemplate, Nostr, VerifiedEvent } from './core.ts'
|
||||||
import { type Filter } from './filter.ts'
|
import { type Filter } from './filter.ts'
|
||||||
import { alwaysTrue } from './helpers.ts'
|
import { alwaysTrue } from './helpers.ts'
|
||||||
|
|
||||||
export type SubCloser = { close: () => void }
|
export type SubCloser = { close: (reason?: string) => void }
|
||||||
|
|
||||||
export type AbstractPoolConstructorOptions = AbstractRelayConstructorOptions & {}
|
export type AbstractPoolConstructorOptions = AbstractRelayConstructorOptions & {}
|
||||||
|
|
||||||
|
@ -179,10 +179,10 @@ export class AbstractSimplePool {
|
||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
async close() {
|
async close(reason?: string) {
|
||||||
await allOpened
|
await allOpened
|
||||||
subs.forEach(sub => {
|
subs.forEach(sub => {
|
||||||
sub.close()
|
sub.close(reason)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ export class AbstractSimplePool {
|
||||||
const subcloser = this.subscribe(relays, filter, {
|
const subcloser = this.subscribe(relays, filter, {
|
||||||
...params,
|
...params,
|
||||||
oneose() {
|
oneose() {
|
||||||
subcloser.close()
|
subcloser.close('closed automatically on eose')
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
return subcloser
|
return subcloser
|
||||||
|
@ -214,7 +214,7 @@ export class AbstractSimplePool {
|
||||||
const subcloser = this.subscribeMany(relays, filters, {
|
const subcloser = this.subscribeMany(relays, filters, {
|
||||||
...params,
|
...params,
|
||||||
oneose() {
|
oneose() {
|
||||||
subcloser.close()
|
subcloser.close('closed automatically on eose')
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
return subcloser
|
return subcloser
|
||||||
|
|
Loading…
Reference in New Issue