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

Exception handling in events #175

Open
jcalfee opened this issue Mar 28, 2023 · 4 comments
Open

Exception handling in events #175

jcalfee opened this issue Mar 28, 2023 · 4 comments

Comments

@jcalfee
Copy link

jcalfee commented Mar 28, 2023

What about an exception to notify the caller that is trying to make the action succeed? Are their any parameters for abort and what happens if an exception is passed to abort or thrown?

https://github.com/nanostores/nanostores#store-events

import { onSet } from 'nanostores'

onSet(store, ({ newValue, abort }) => {
  if (!validate(newValue)) {
    abort()
  }
})
@ai
Copy link
Member

ai commented Mar 28, 2023

No right now. The current plan is to keep event system simple and create complex logic on top of it (but we can change this plan).

What you try to do and why?

@jcalfee
Copy link
Author

jcalfee commented Mar 29, 2023

Nothing specific, I'm evaluating to maybe add Svelte into a Vue environment.. I can't imagine the caller not needing to know the change did not take effect.

@ai
Copy link
Member

ai commented Apr 3, 2023

What API do you think of? If you want and it will be simple, you can send PR.

@ai
Copy link
Member

ai commented Apr 13, 2023

In recent 0.8 release we added onAction event with error callback. Not sure that it will cover all onSet events. Maybe we should add onError listener.

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

2 participants