adamritter / nostr-relaypool-ts

A Nostr RelayPool implementation in TypeScript using only nostr-tools library as a dependency
https://www.npmjs.com/package/nostr-relaypool
MIT License
63 stars 17 forks source link

Get 1 event #10

Closed adamritter closed 1 year ago

adamritter commented 1 year ago

Implementing subscription merging, delaying and caching gives us an amazing abstraction that can be used from the components without extra logic for managing data: getting one event. After implementing the other features this function is trivial to implement and joy to work with.

adamritter commented 1 year ago

The more I'm thinking about implementing this function, the more questions pop up for the right semantic.

The right way to look at kind 0 / 3 events is one that has one value that can be updated, which is represented as a reader store with always the newest value (and starting with undefined), and there's no new function that can help in that Svelte reader store abstraction.

Probably what can be safely added to the API is a

getEventById(id: string, delayms?: number, options?: {noCache: boolean}) : Promise<Event>