@welshman/store
v0.0.14
Published
A collection of utilities based on svelte/store for use with welshman
Downloads
563
Readme
@welshman/store
Utilities for dealing with svelte stores when using welshman.
import {Repository, NAMED_PEOPLE, NAMED_TOPICS, type TrustedEvent, readUserList, List} from '@welshman/util'
import {deriveEventsMapped} from '@welshman/store'
const repository = new Repository()
// Create a svelte store that performantly maps matching events in the repository to List objects
const lists = deriveEventsMapped<PublishedUserList>(repository, {
filters: [{kinds: [NAMED_PEOPLE, NAMED_TOPICS]}],
eventToItem: (event: TrustedEvent) => (event.tags.length > 1 ? readUserList(event) : null),
itemToEvent: (list: List) => list.event,
})