Skip to content

Add ability to hook into method calls for side effects #759

Description

@comatory

I'd like if the library had an API to hook into method calls. Imagine a toast.error is called and I'd like to capture the error via telemetry globally for any instance of that method call.
I know I can work around this by:

  • creating a helper function
  • monkey-patching .error

Could we have a global API which would allow me to hook into the methods? Using events would be ok:

toast.addEventListener('toast_error', (err) => /* call custom code */)
toast.removeEventListener(/* you get the idea */)

or even something like:

toast.setup({
   onError: (err) => /* call custom code */
})

I'm mentioning the error style of toasts, but I can imagine being able to intercept any kind of event.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions