11 Flash
(require koyo/flash) | package: koyo-lib |
This module exposes a component for storing and retrieving flash messages. Flash messages which are set on one page, are available for display on the next and then cleared as soon as the next page is processed. Each message is bound to a specific user session.
parameter
(current-flash-messages) → (listof (cons/c symbol? string?))
(current-flash-messages messages) → void? messages : (listof (cons/c symbol? string?))
This parameter holds the set of flash messages for the current
request.
parameter
(current-flash-manager) → (or/c #f flash-manager?)
(current-flash-manager flashes) → void? flashes : (or/c #f flash-manager?)
This parameters holds the current flash manager for a particular
request. It is installed by wrap-flash and automatically
used by flash if an explicit manager is not passed in.
procedure
(flash-manager? v) → boolean?
v : any/c
Returns #t when v is a flash manager.
procedure
(make-flash-manager sessions) → flash-manager?
sessions : session-manager?
Creates a new flash manager which stores its messages using
sessions.
procedure
((wrap-flash flashes) handler)
→ (-> request? any/c ... response?) flashes : flash-manager? handler : procedure?
Wraps a handler such that flash messages from the previous request
get collected into current-flash-messages and then cleared
from the current session.
This wrapper must be applied after wrap-session.
procedure
key : symbol? message : string? (flash flashes key message) → void? flashes : flash-manager? key : symbol? message : string?
Adds a flash message to the current session. If flashes is
not provided, the current-flash-manager is used.