bcherny / undux

⚡️ Dead simple state for React. Now with Hooks support.

Home Page:https://undux.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to catch errors for all store subscriptions?

negebauer opened this issue · comments

Hi!

How can I react to an error throw inside any subscription the store?
For example if I have

store.on('key').subscribe(() => {
  throw new Error('foo')
})

How could I capture that error? (not inside the subscribe code, but in general for the whole store)

There is no way to do this generically. You could wrap your code in a try/catch if you like.