From 35d331a753efe0f6d5d9c241f4f674f78e9b3a8a Mon Sep 17 00:00:00 2001 From: Alexander Heldt Date: Tue, 25 Nov 2025 20:58:21 +0100 Subject: [PATCH] Update documentation --- src/musicplayer.gleam | 6 ------ src/musicplayer/input/input.gleam | 15 +++++++-------- src/musicplayer/musicplayer.gleam | 4 +++- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/musicplayer.gleam b/src/musicplayer.gleam index b47b459..b3cbcb3 100644 --- a/src/musicplayer.gleam +++ b/src/musicplayer.gleam @@ -8,14 +8,8 @@ import musicplayer/ui/ui pub fn main() -> Nil { let input_keys_name: Name(Key) = process.new_name("input_keys") - - // `input_inject` is created by name to allow the `input` process that - // owns `read_input` to be able to register and receive from it, - // while the any other processes can use the name reference to - // inject input let input_inject_name: Name(Key) = process.new_name("input_inject_keys") - // TODO should input.new just return the inject_subject? input.new(input_keys_name, input_inject_name) let assert Ok(ui) = ui.new() diff --git a/src/musicplayer/input/input.gleam b/src/musicplayer/input/input.gleam index 8f82502..87ff05a 100644 --- a/src/musicplayer/input/input.gleam +++ b/src/musicplayer/input/input.gleam @@ -2,14 +2,13 @@ import gleam/erlang/process.{type Name} import musicplayer/input/key.{type Key} -// TODO REWRITE below - -/// `new` accepts a list of listeners that are composed of two subjects; -/// - one to get the final `Key` and -/// - one to tap the input as it is read from i/o -/// and -/// - a subject name that is used to create a `Subject` that other processes -/// know they can inject a `Key` into the input with +/// `new` accepts two named subjects: +/// - one to send the input to, and +/// - one to receive injected input from +/// +/// The subject for input injection is used to allow the `input` process that +/// owns `read_input` to be able to register and receive from it, while +/// the any other processes can use the name reference to inject input pub fn new(input_keys_name: Name(Key), input_inject_name: Name(Key)) -> Nil { let _ = process.spawn(fn() { diff --git a/src/musicplayer/musicplayer.gleam b/src/musicplayer/musicplayer.gleam index 51d91ee..deb4034 100644 --- a/src/musicplayer/musicplayer.gleam +++ b/src/musicplayer/musicplayer.gleam @@ -134,7 +134,9 @@ fn update_search(ui: Subject(ui_control.Control), content: String) -> Nil { } /// `handle_key` listens to a subject onto which `input` will send messages with -/// parsed `Key`s which will be mapped to `Control`s (if possible) +/// `Key`s. The keys can be either be +/// - instances of `Continue` which are "streamed"input, or +/// - instances of "final" keys that are the result of "end of input" fn handle_key(musicplayer: Subject(Control), input_keys: Subject(Key)) -> Nil { let _ = case process.new_selector()