Skip to main content

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

- idStringRequired. The id of the toast to change, as returned by show.
- messageStringThe new text, up to 1000 characters.
- titleStringThe new heading, up to 1000 characters.
- typeStringinfo, success, warning, error or default.
- positionStringtop-left, top-center, top-right, bottom-left, bottom-center or bottom-right.
- animateStringbounce, slide, zoom or flip.
- autoCloseIntegerMilliseconds before the toast closes. 0 keeps it open until it is dismissed.
- closeButtonBooleanShow the close button.
- pauseOnHoverBooleanPause the auto-close timer while the pointer is over the toast.
- draggableBooleanAllow the toast to be swiped away.
- loadingBooleanKeep the spinner showing.
- sessionIdStringThe session the toast is in. Required from Gateway scripts.
- pageIdStringThe 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)