mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-09 16:48:50 +00:00
add channel reusing and cancellation to README.
This commit is contained in:
20
README.md
20
README.md
@@ -26,14 +26,24 @@ pool.sub({cb: onEvent, filter: {author: '<hex>'}})
|
|||||||
// or bulk follow
|
// or bulk follow
|
||||||
pool.sub({cb:(event, relay) => {...}, filter: {authors: ['<hex1>', '<hex2>', ..., '<hexn>']}})
|
pool.sub({cb:(event, relay) => {...}, filter: {authors: ['<hex1>', '<hex2>', ..., '<hexn>']}})
|
||||||
|
|
||||||
|
// reuse a subscription channel
|
||||||
|
const mySubscription = pool.sub({cb: ..., filter: ....})
|
||||||
|
mySubscription.sub({filter: ....})
|
||||||
|
mySubscription.sub({cb: ...})
|
||||||
|
mySubscription.unsub()
|
||||||
|
|
||||||
// get specific event
|
// get specific event
|
||||||
pool.sub({cb: (event, relay) => {...}, filter: {id: '<hex>'}})
|
const specificChannel = pool.sub({
|
||||||
// or get a specific event plus all the events that reference it in the 'e' tag
|
cb: (event, relay) => {
|
||||||
pool.sub({
|
console.log('got specific event from relay', event, relay)
|
||||||
cb: (event, relay) => {...},
|
specificChannel.unsub()
|
||||||
filter: [{id: '<hex>'}, {'#e': '<hex>'}]
|
},
|
||||||
|
filter: {id: '<hex>'}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// or get a specific event plus all the events that reference it in the 'e' tag
|
||||||
|
pool.sub({ cb: (event, relay) => { ... }, filter: [{id: '<hex>'}, {'#e': '<hex>'}] })
|
||||||
|
|
||||||
// get all events
|
// get all events
|
||||||
pool.sub({cb: (event, relay) => {...}, filter: {}})
|
pool.sub({cb: (event, relay) => {...}, filter: {}})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user