From 12acb900abe5fa324b04bd562de0088bc301b6dc Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Tue, 10 Jun 2025 10:15:58 -0300 Subject: [PATCH] SubCloser.close() can take a reason string optionally. --- abstract-pool.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/abstract-pool.ts b/abstract-pool.ts index 33bd57e..542abd4 100644 --- a/abstract-pool.ts +++ b/abstract-pool.ts @@ -12,7 +12,7 @@ import type { Event, EventTemplate, Nostr, VerifiedEvent } from './core.ts' import { type Filter } from './filter.ts' import { alwaysTrue } from './helpers.ts' -export type SubCloser = { close: () => void } +export type SubCloser = { close: (reason?: string) => void } export type AbstractPoolConstructorOptions = AbstractRelayConstructorOptions & {} @@ -179,10 +179,10 @@ export class AbstractSimplePool { ) return { - async close() { + async close(reason?: string) { await allOpened subs.forEach(sub => { - sub.close() + sub.close(reason) }) }, } @@ -198,7 +198,7 @@ export class AbstractSimplePool { const subcloser = this.subscribe(relays, filter, { ...params, oneose() { - subcloser.close() + subcloser.close('closed automatically on eose') }, }) return subcloser @@ -214,7 +214,7 @@ export class AbstractSimplePool { const subcloser = this.subscribeMany(relays, filters, { ...params, oneose() { - subcloser.close() + subcloser.close('closed automatically on eose') }, }) return subcloser