aboutsummaryrefslogtreecommitdiff
path: root/script.it
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2022-02-07 15:48:26 +0100
committerSébastien Dailly <sebastien@dailly.me>2022-02-07 16:22:43 +0100
commit52cbf99e0db1c0fb7b44f4101c6a673d9ec1fbbe (patch)
tree5f128dec73514dc62ab425c40d585a45bc9f6f3f /script.it
parent6a75fb043ed30389fff1ce97fe20ee56b1c95066 (diff)
Update application workflow
Diffstat (limited to 'script.it')
-rwxr-xr-xscript.it/script.ml23
-rwxr-xr-xscript.it/state/state.ml18
2 files changed, 12 insertions, 29 deletions
diff --git a/script.it/script.ml b/script.it/script.ml
index 29bf2c9..6c2b5d3 100755
--- a/script.it/script.ml
+++ b/script.it/script.ml
@@ -87,7 +87,7 @@ type 'a param_events =
; angle : float S.t
; export : unit E.t
; delete : unit E.t
- ; rendering : State.events E.t
+ ; rendering : State.event E.t
}
type slider =
@@ -174,7 +174,7 @@ let set_sidebar
State.E
( render_type
- , (module M: State.Handler with type t = Layer.Paths.printer ))
+ , (module M: State.Event with type t = Layer.Paths.printer ))
) rendering' in
@@ -377,7 +377,7 @@ let page_main id =
let module Delete = Script_event.Delete in
State.E
( Delete.{ worker }
- , (module Delete: State.Handler with type t = Delete.t )))
+ , (module Delete: State.Event with type t = Delete.t )))
parameters.delete
and export_event =
@@ -385,21 +385,21 @@ let page_main id =
let module Export = Script_event.Export in
State.E
( ()
- , (module Export: State.Handler with type t = Export.t )))
+ , (module Export: State.Event with type t = Export.t )))
parameters.export
and angle_event = S.changes parameters.angle
|> E.map (fun value ->
let module Property = Script_event.Property in
State.E
( Property.{ value ; worker ; prop = `Angle }
- , (module Property: State.Handler with type t = Property.t )))
+ , (module Property: State.Event with type t = Property.t )))
and width_event = S.changes parameters.width
|> E.map (fun value ->
let module Property = Script_event.Property in
State.E
( Property.{ value ; worker ; prop = `Width }
- , (module Property: State.Handler with type t = Property.t )))
+ , (module Property: State.Event with type t = Property.t )))
and worker_event = Note.E.filter_map
(function
| `Other t ->
@@ -410,7 +410,7 @@ let page_main id =
Some (
State.E
( outline
- , (module Complete_path: State.Handler with type t = Complete_path.t ))))
+ , (module Complete_path: State.Event with type t = Complete_path.t ))))
worker_event
in
@@ -439,13 +439,13 @@ let page_main id =
let module MouseDown = Script_event.Mouse_down in
State.E
( MouseDown.{ position = c ; timer }
- , (module MouseDown: State.Handler with type t = MouseDown.t ))
+ , (module MouseDown: State.Event with type t = MouseDown.t ))
| `Out c ->
let module Click = Script_event.Click in
State.E
( Click.{ point = c ; worker; timer }
- , (module Click: State.Handler with type t = Click.t ))
+ , (module Click: State.Event with type t = Click.t ))
) canva_events in
let tick_event =
@@ -456,14 +456,13 @@ let page_main id =
Option.map (fun p ->
State.E
( (f, p)
- , (module Tick: State.Handler with type t = Tick.t )))
+ , (module Tick: State.Event with type t = Tick.t )))
pos ) in
(* The first evaluation is the state. Which is the result of all the
successives events to the initial state *)
let state =
- Application.run
- State.do_action
+ State.run
State.init
(E.select
[ worker_event
diff --git a/script.it/state/state.ml b/script.it/state/state.ml
index e8cd87e..f3be91d 100755
--- a/script.it/state/state.ml
+++ b/script.it/state/state.ml
@@ -19,17 +19,7 @@ type state =
; mouse_down_position : Gg.v2
}
-module type Handler = sig
-
- type t
-
- val update: t -> state -> state
-
-end
-
-type t = E : 'a * (module Handler with type t = 'a) -> t
-
-type events = t
+include Application.Make(struct type t = state end)
let post
: Brr_webworkers.Worker.t -> Worker_messages.to_worker -> unit
@@ -73,12 +63,6 @@ let select_segment _ (_, selected, p0, p1) state dist =
; width }
-let do_action
- : (events, state) Application.t
- = fun (E (t, (module Handler))) state ->
- Handler.update t state
-
-
let init =
{ paths = []
; current = Path.Path_Builder.empty