MingaEditor.State.Session (Minga v0.1.0)

Copy Markdown View Source

Session persistence state for the Editor.

Groups the Editor's session-related fields into a focused sub-struct: the periodic save timer and the directory paths for session files and swap files. These are set once at startup and only the timer mutates during the Editor's lifetime.

All mutations go through functions on this module.

Summary

Functions

Records a timer reference created by the session workflow.

Returns a pure instruction for canceling the save timer.

Clears a completed or canceled quit request.

Latches completion of the one-time editor startup workflow.

Returns true if session persistence is enabled (session_dir is set).

Creates a new session state from startup options.

Remembers the command and project root used by the last test run.

Requests quit confirmation for the editor or all editor instances.

Returns a pure instruction for restarting the save timer.

Returns keyword options for Minga.Session functions.

Returns a pure instruction for starting the periodic save timer.

Returns true if swap file recovery is enabled (swap_dir is set).

Returns keyword options for swap recovery functions.

Returns the interval used by the session workflow's periodic save timer.

Types

last_test_command()

@type last_test_command() :: {String.t(), String.t()} | nil

pending_quit()

@type pending_quit() :: :quit | :quit_all | nil

t()

@type t() :: %MingaEditor.State.Session{
  last_test_command: last_test_command(),
  pending_quit: pending_quit(),
  session_dir: String.t() | nil,
  session_started?: boolean(),
  swap_dir: String.t() | nil,
  timer: reference() | nil
}

Functions

accept_timer(session, ref)

@spec accept_timer(t(), reference()) :: t()

Records a timer reference created by the session workflow.

cancel_timer(session)

@spec cancel_timer(t()) :: {:cancel_timer, t(), reference() | nil}

Returns a pure instruction for canceling the save timer.

clear_quit_request(session)

@spec clear_quit_request(t()) :: t()

Clears a completed or canceled quit request.

complete_startup(current, started)

@spec complete_startup(t(), t()) :: t()

Latches completion of the one-time editor startup workflow.

enabled?(session)

@spec enabled?(t()) :: boolean()

Returns true if session persistence is enabled (session_dir is set).

new(opts \\ [])

@spec new(keyword()) :: t()

Creates a new session state from startup options.

remember_test_command(session, command)

@spec remember_test_command(t(), last_test_command()) :: t()

Remembers the command and project root used by the last test run.

request_quit(session, request)

@spec request_quit(t(), :quit | :quit_all) :: t()

Requests quit confirmation for the editor or all editor instances.

restart_timer(session)

@spec restart_timer(t()) :: {:restart_timer, t(), reference() | nil}

Returns a pure instruction for restarting the save timer.

session_opts(session)

@spec session_opts(t()) :: keyword()

Returns keyword options for Minga.Session functions.

start_timer(session)

@spec start_timer(t()) :: {:start_timer, t()} | {:no_timer, t()}

Returns a pure instruction for starting the periodic save timer.

swap_enabled?(session)

@spec swap_enabled?(t()) :: boolean()

Returns true if swap file recovery is enabled (swap_dir is set).

swap_opts(session)

@spec swap_opts(t()) :: keyword()

Returns keyword options for swap recovery functions.

timer_interval()

@spec timer_interval() :: pos_integer()

Returns the interval used by the session workflow's periodic save timer.