system.kanoa.toast.update(paramsDict)
Changes a toast notification that is still on screen. Takes the same keys as show, and id is required. The message and title are replaced, so pass both again if both should stay. Updating a toast that has already closed does nothing.
Updating a loading toast without "loading": True stops the spinner and gives it back its close button and auto-close timer. Pass "loading": True again to change the message while keeping the spinner, for example to show progress.
When updating from a Gateway script or a background thread, pass the sessionId and pageId the toast was shown on.
Parameters
paramsDict Dictionary
| - id | String | Required. The id of the toast to change, as returned by show. |
| - message | String | The new text, up to 1000 characters. |
| - title | String | The new heading, up to 1000 characters. |
| - type | String | info, success, warning, error or default. |
| - position | String | top-left, top-center, top-right, bottom-left, bottom-center or bottom-right. |
| - animate | String | bounce, slide, zoom or flip. |
| - autoClose | Integer | Milliseconds before the toast closes. 0 keeps it open until it is dismissed. |
| - closeButton | Boolean | Show the close button. |
| - pauseOnHover | Boolean | Pause the auto-close timer while the pointer is over the toast. |
| - draggable | Boolean | Allow the toast to be swiped away. |
| - loading | Boolean | Keep the spinner showing. |
| - sessionId | String | The session the toast is in. Required from Gateway scripts. |
| - pageId | String | The page the toast is on. Required from Gateway scripts. |
Returns
Example
toastId = system.kanoa.toast.show({"message": "Releasing lot 123...", "loading": True})
try:
releaseLot(123)
system.kanoa.toast.update({"id": toastId, "message": "Lot 123 released", "type": "success"})
except:
system.kanoa.toast.update({"id": toastId, "message": "Release failed", "type": "error"})
raise
# From a background thread, pass the session and page ids read before it started
sessionId, pageId = self.session.props.id, self.page.props.pageId
toastId = system.kanoa.toast.show({"message": "Working...", "loading": True})
def work():
# ... long task ...
system.kanoa.toast.update({"id": toastId, "message": "Done", "type": "success",
"sessionId": sessionId, "pageId": pageId})
system.util.invokeAsynchronous(work)