a better way to do pubs and subs with SimplePool.

This commit is contained in:
fiatjaf
2023-02-08 14:15:29 -03:00
parent 75d7be5a54
commit b2d1dd2110
3 changed files with 35 additions and 20 deletions

View File

@@ -4,14 +4,10 @@ import {Filter} from './filter'
import {Event} from './event'
import {SubscriptionOptions, Sub, Pub} from './relay'
export function pool(defaultRelays: string[] = []) {
return new SimplePool(defaultRelays)
}
class SimplePool {
export class SimplePool {
private _conn: {[url: string]: Relay}
constructor(defaultRelays: string[]) {
constructor(defaultRelays: string[] = []) {
this._conn = {}
defaultRelays.forEach(this.ensureRelay)
}