Skip to content
Flow-UILive

Actions

The built in action types and the contract for defining your own.

An action is { "type": "...", ...anything }. The whole object reaches the handler for that type, so each type defines its own extra keys.

Built in types#

json
{ "type": "toast", "message": "Saved", "duration": 2.5 }
{ "type": "dismiss" }
{ "type": "refresh_page" }
{ "type": "open_bottom_sheet", "sheet": {} }
{ "type": "api", "endpoint": "anything/you/like" }
FieldTypeDefaultDescription
toastactionFloating message. message required, duration optional seconds.
dismissactionCloses the active sheet, else requests screen dismissal from the host.
refresh_pageactionReloads the page through the loader, keeping content visible meanwhile.
open_bottom_sheetactionPresents the inline SheetModel under the sheet key.
apiactionRound trips the full action object through the loader; the response is an ActionResponse of mutations.

Host defined types#

Anything else, deeplink included, belongs to the host app. Handlers are consulted newest first; the first to return true consumes the action, which also lets hosts override built ins.

swift
public protocol ActionHandler {
    func handle(_ action: ActionData, context: ActionContext) async -> Bool
}

ActionContext exposes the source widget id, the page store for mutations, and the presenter for sheets and toasts.

Events#

Widgets fire actions by event name. The renderer wires tap and long_press on the envelope; widgets fire their own named events such as change.