callNotified()function
callNotified(callback: NoticeCallback<A>, ...args: A): boolean | Promise<boolean>
| Param | Type | |
|---|---|---|
callback | NoticeCallback<A> | The callback to run, whose return/throw drives the notice. required |
args | A | 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 vianotifyThrown(). - Resolves asynchronously when the callback returns a promise.
Examples
callNotified(() => save()); // notifies "success" or "error"