diff --git a/README.md b/README.md index f7d3230..8103dd3 100644 --- a/README.md +++ b/README.md @@ -26,14 +26,24 @@ pool.sub({cb: onEvent, filter: {author: ''}}) // or bulk follow pool.sub({cb:(event, relay) => {...}, filter: {authors: ['', '', ..., '']}}) +// reuse a subscription channel +const mySubscription = pool.sub({cb: ..., filter: ....}) +mySubscription.sub({filter: ....}) +mySubscription.sub({cb: ...}) +mySubscription.unsub() + // get specific event -pool.sub({cb: (event, relay) => {...}, filter: {id: ''}}) -// or get a specific event plus all the events that reference it in the 'e' tag -pool.sub({ - cb: (event, relay) => {...}, - filter: [{id: ''}, {'#e': ''}] +const specificChannel = pool.sub({ + cb: (event, relay) => { + console.log('got specific event from relay', event, relay) + specificChannel.unsub() + }, + filter: {id: ''} }) +// or get a specific event plus all the events that reference it in the 'e' tag +pool.sub({ cb: (event, relay) => { ... }, filter: [{id: ''}, {'#e': ''}] }) + // get all events pool.sub({cb: (event, relay) => {...}, filter: {}})