Skip to content

Commit

Permalink
[leostera#46] Configurable fps for app start
Browse files Browse the repository at this point in the history
  • Loading branch information
chshersh committed Jun 21, 2024
1 parent b084ec7 commit 5916a9a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
4 changes: 2 additions & 2 deletions examples/list/dune
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(executable
(name main)
(libraries minttea spices leaves str))
(name main)
(libraries minttea spices leaves str))
14 changes: 11 additions & 3 deletions minttea/minttea.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,28 @@ module Command = Command
module App = App
module Program = Program

type config = {
fps: int;
}

let make_config ?(fps = 60) () = {fps}

let default_config = make_config ()

let app = App.make

let run ?(fps = 60) ~initial_model app =
let run ?fps ~initial_model app =
let prog = Program.make ~app ~fps in
Program.run prog initial_model;
Logger.trace (fun f -> f "terminating")

let start app ~initial_model =
let start ?(config = default_config) app ~initial_model =
let module App = struct
let start () =
Logger.set_log_level None;
let pid =
spawn_link (fun () ->
run app ~initial_model;
run ~fps:config.fps app ~initial_model;
Logger.trace (fun f -> f "about to shutdown");
shutdown ~status:0 ())
in
Expand Down
12 changes: 11 additions & 1 deletion minttea/minttea.mli
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,15 @@ val app :
unit ->
'model App.t

(** Configuration for a TUI app. Use {!make_config} to create a configuration value. *)
type config

(** Create a configuration to be used by {!start}. Default configuration parameters are:
- [fps]: 60
*)
val make_config: ?fps:int -> unit -> config

val run : ?fps:int -> initial_model:'model -> 'model App.t -> unit
val start : 'model App.t -> initial_model:'model -> unit
val start : ?config:config -> 'model App.t -> initial_model:'model -> unit

0 comments on commit 5916a9a

Please sign in to comment.