callNotified()function

callNotified(callback: NoticeCallback<A>, ...args: A): boolean | Promise<boolean>
ParamType
callbackNoticeCallback<A>
The callback to run, whose return/throw drives the notice. required
argsA
Arguments forwarded to the callback. required
Return
boolean | Promise<boolean>
true if the callback succeeded, false if it threw (a Promise of the same when async).

Run a callback and dispatch a success or error notice to the window based on its return or throw.

  • A returned truthy value becomes a "success" notice; a thrown value becomes an "error" notice via notifyThrown().
  • Resolves asynchronously when the callback returns a promise.

Examples

callNotified(() => save()); // notifies "success" or "error"