Commit 0702a647 authored by Laurent Wouters's avatar Laurent Wouters
Browse files

Adding new application framework

parent 2ea315e9ec59
......@@ -164,6 +164,9 @@ module States : sig
(* When the state has changed *)
val on_updated: (appState, 'retainedProps, appAction) ReasonReact.oldNewSelf -> unit
(* Gets the root resource from an application state *)
val root_resource: appState -> resource
end = struct
(* Fold fetched data into a map of resources *)
let append_resource fetchedData (resources: resource StringMap.t) =
......@@ -182,6 +185,22 @@ end = struct
StringMap.add target {path=target; schema=None; data=Some(data)} resources
| _ -> resources
(* Gets the root resource from an application state *)
let root_resource (state: appState) = match state with
| Init(_)
| Failed(_) -> raise (BadState "Expected state Loading or Ready")
| Loading({
location = location;
loaded = resources;
requested = _;
registry = _;
})
| Ready({
location = location;
resources = resources;
registry = _;
}) -> StringMap.find location resources
(* Get the initial state for the application *)
let initial_state viewRegistry = Init(viewRegistry)
......
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