Extract reading of input i/o to input
And add the ability of other modules to listen to either the final result (a `Key`) or tap into the input as it is read
This commit is contained in:
@@ -1,8 +1,22 @@
|
||||
import gleam/erlang/process
|
||||
import gleam/erlang/process.{type Name}
|
||||
|
||||
import input/input.{type Listener}
|
||||
import input/key.{type Key}
|
||||
import mpv/mpv
|
||||
|
||||
pub fn main() -> Nil {
|
||||
let exit = process.new_subject()
|
||||
let assert Ok(_) = mpv.new(exit)
|
||||
|
||||
// `inject_input` 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 inject_input_name: Name(Key) = process.new_name("inject_input")
|
||||
|
||||
let assert Ok(mpv_listener) = mpv.new(exit)
|
||||
|
||||
let listeners: List(Listener) = [mpv_listener]
|
||||
|
||||
input.new(listeners, inject_input_name)
|
||||
process.receive_forever(exit)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user