Commit ac30cbd4 authored by Laurent Wouters's avatar Laurent Wouters
Browse files

Adding new application framework

parent e28c173f3b15
......@@ -129,7 +129,7 @@ and appState =
| Ready of appStateLoaded
(* The possible actions of an app *)
type appAction =
and appAction =
(* Some fetching is being requested *)
| Request of requestedData
(* Some request has been launched *)
......@@ -371,7 +371,7 @@ end
(* Module for rendering *)
module Rendering : sig
(* Renders an application state *)
val render: appState -> ReasonReact.reactElement
val get_view: appState -> view
end = struct
(* Select the view if it is appropriate for this kind *)
let best_of_1 (view: view) (kind: viewKind) = match view.specification.kind, kind with
......@@ -412,7 +412,7 @@ end = struct
| _ -> RootView
(* Get the appropriate view and resources from the application state *)
let get_view state = match state with
let do_get_view state = match state with
| Init(registry)
| Loading({
location = _;
......@@ -430,12 +430,10 @@ end = struct
let kind = view_kind_for_resource resource in
select_view registry kind
(* Renders an application state *)
let render state =
let maybe_view = get_view state in
match maybe_view with
| None -> ReasonReact.null
| Some(view) -> view.renderer state
(* Get the appropriate view and resources from the application state *)
let get_view state = match do_get_view state with
| None -> raise (BadState "Could not find a view")
| Some(view) -> view
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment