The Elm Architecture event loop for TUI applications.
A program consists of:
Commands are functions that produce messages asynchronously.
The Elm Architecture event loop for TUI applications. A program consists of: - init: Initial state and optional startup command - update: (state, msg) -> [new-state, cmd] - view: state -> string Commands are functions that produce messages asynchronously.
(batch & cmds)Combine multiple commands into one.
Combine multiple commands into one.
(cmd f)Create a command from a function that returns a message. The function will be called asynchronously.
Create a command from a function that returns a message. The function will be called asynchronously.
Command that sends a quit message.
Command that sends a quit message.
(run {:keys [init update view running?] :as opts})Run a TUI program.
Options: :init - (fn [] [initial-state cmd]) or initial state value :update - (fn [state msg] [new-state cmd]) :view - (fn [state] string) :alt-screen - Use alternate screen buffer (default: false) :mouse - Mouse mode: nil, :normal, :cell, or :all (default: nil) :focus-reporting - Report focus in/out (default: false) :fps - Frames per second (default: 60) :hide-cursor - Hide cursor (default: true) :running? - Atom to control the event loop externally (default: internal atom)
The init function should return [initial-state cmd] or just initial-state. The update function receives (state msg) and returns [new-state cmd]. Commands are optional and can be nil.
Run a TUI program. Options: :init - (fn [] [initial-state cmd]) or initial state value :update - (fn [state msg] [new-state cmd]) :view - (fn [state] string) :alt-screen - Use alternate screen buffer (default: false) :mouse - Mouse mode: nil, :normal, :cell, or :all (default: nil) :focus-reporting - Report focus in/out (default: false) :fps - Frames per second (default: 60) :hide-cursor - Hide cursor (default: true) :running? - Atom to control the event loop externally (default: internal atom) The init function should return [initial-state cmd] or just initial-state. The update function receives (state msg) and returns [new-state cmd]. Commands are optional and can be nil.
(run-async opts)Run a TUI program in the background. Returns a handle: :quit! - (fn [] ...) stop the program :result - promise, deref to get the final state
Accepts the same options as run.
Run a TUI program in the background. Returns a handle: :quit! - (fn [] ...) stop the program :result - promise, deref to get the final state Accepts the same options as `run`.
(sequence-cmds & cmds)Run commands in sequence (each waits for previous to complete).
Run commands in sequence (each waits for previous to complete).
(window-size-msg width height)Create a window size message.
Create a window size message.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |