Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NDK-Svelte Store Subscription should support fine-grained event handling #227

Open
Pleb5 opened this issue May 17, 2024 · 0 comments
Open

Comments

@Pleb5
Copy link
Contributor

Pleb5 commented May 17, 2024

It is impossible to reliably attach a fine-grained callback (subscription.on(...)=>{} ) on ndk svelte store subscriptions.

Purpose: storeSubscriptions are great to handle a collection of Svelte components but sometimes it is necessary to react with extra logic on the newest unique event that arrived. E.g. render a list of components of which one might belong to the user and the app has to react based on this one event that may be present or not.

Cause: store.subscription is undefined unitl startSubscription() is called. It is not possible to attach a callback before the subsciption start therefore. If the callback is attached AFTER startSubscription() then some events will be missed by the callback by that time.

Fix: Everything is already given in the storeSubscribe() method to assign value to store.subscription (filters, opts). The assignment code in startSubscription() should be moved in this method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant