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

Cancels the session save timer and clears the reference.

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

Creates a new session state from startup options.

Restarts the timer: cancels any existing timer and starts a new one.

Returns keyword options for Minga.Session functions.

Starts the periodic session save timer. No-op if session_dir is nil.

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

Returns keyword options for swap recovery functions.

Types

t()

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

Functions

cancel_timer(session)

@spec cancel_timer(t()) :: t()

Cancels the session save timer and clears the reference.

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.

restart_timer(session)

@spec restart_timer(t()) :: t()

Restarts the timer: cancels any existing timer and starts a new one.

session_opts(session)

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

Returns keyword options for Minga.Session functions.

start_timer(session)

@spec start_timer(t()) :: t()

Starts the periodic session save timer. No-op if session_dir is nil.

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.