Update docs, tweak url based event derivation

This commit is contained in:
Jon Staab
2025-11-20 15:08:59 -08:00
parent 6d36f5a912
commit 2fec078a5b
12 changed files with 154 additions and 317 deletions
+5 -4
View File
@@ -16,15 +16,16 @@ A utility package providing welshman-specific svelte store functionality and uti
```typescript
import {Repository, NAMED_PEOPLE, TrustedEvent, PublishedList, readList} from '@welshman/util'
import {deriveEventsMapped} from '@welshman/store'
import {deriveItemsByKey} from '@welshman/store'
const repository = new Repository()
// Create a store that performantly maps matching events in the repository to List objects
const lists = deriveEventsMapped<PublishedList>(repository, {
// Create a reactive map of lists indexed by pubkey
const listsByPubkey = deriveItemsByKey<PublishedList>({
repository,
filters: [{kinds: [NAMED_PEOPLE]}],
eventToItem: (event: TrustedEvent) => (event.tags.length > 1 ? readList(event) : null),
itemToEvent: (list: PublishedList) => list.event,
getKey: (list: PublishedList) => list.event.pubkey,
})
```