Solidtype.SolidSolid's reactive core, solid-js, at 1.9.
Names are Solid's, in snake case, so Solid's documentation reads across: createSignal is create_signal. An options object is optional arguments. Where Solid passes a computation its previous value, the binding is two functions, the second ending in _from and taking ~init.
A reactive value, read by get. A JavaScript function, so a read is a plain call that Solid tracks.
val get : 'a accessor -> 'aget count reads count, and inside a tracking scope -- a thunk in a JSX position, an effect, a memo -- subscribes to it.
By default a value === to the last is no change.
val set : 'a setter -> 'a -> unitset s v makes v the signal's value, a function too: Solid calls a function it is given, so a function value is passed through one that returns it.
val update : 'a setter -> ('a -> 'a) -> unitupdate s f makes f of the value the new value.
A derived value, recomputed when what it reads changes, and notifying only when it is a change.
As create_memo, given its previous value, init the first time.
Runs after rendering, and again whenever what it reads changes.
As create_effect, run first while rendering, before the DOM is connected.
Runs at once, and again before anything that reads what it writes.
val create_deferred :
?timeout_ms:int ->
?equals:'a equals ->
?name:string ->
(unit -> 'a) ->
'a accessorA copy of a value that changes only once the browser is idle, or after timeout_ms.
create_selector source gives is k, tracked for k alone: a change of source notifies only the keys that become or stop being selected.
create_reaction on_invalidate gives track: track f runs f, and the next change of what f read calls on_invalidate, once.
create_effect (on deps f) runs f input previous_input when deps changes, reading nothing else tracked; ~defer:true skips the first run.
As on, for the _from computations.
val create_root : ?owner:owner -> ((unit -> unit) -> 'a) -> 'acreate_root f runs f dispose in a new root, which lives until dispose is called.
val get_owner : unit -> owner optionval run_with_owner : owner -> (unit -> 'a) -> 'a optionrun_with_owner o f runs f as o's, for a computation or a context reached from a callback; None when f raised, which Solid passes to the owner's error handler.
catch_error f handler runs f: Some what it returned, None when it raised. An error it raises, or one raised later by a computation it created, goes to handler. A value JavaScript threw is Js.Exn.Error.
What JavaScript threw, as Solid hands it to a handler: any value, an OCaml exception among them.
val exn_of_thrown : thrown -> exnWhat JavaScript threw, as an exception: an OCaml one as it was raised -- also when Solid wrapped it in an Error, its cause -- and any other value as Js.Exn.Error.
Deprecated by Solid for catch_error: sends the current owner's errors to handler.
Runs f as a transition: its updates show together, once what they suspend on resolves.
val use_transition :
unit ->
bool accessor * ((unit -> unit) -> unit Js.Promise.t)Whether a transition is pending, and what starts one.
A value fetched asynchronously, read by read.
Where a server-rendered resource's first value comes from: fetched on the server, or its initial_value, fetched in the browser alone.
val create_resource :
?initial_value:'a ->
?name:string ->
?defer_stream:bool ->
?ssr_load_from:ssr_load_from ->
?storage:('a option -> 'a option accessor * 'a option setter) ->
?on_hydrated:('a option -> unit) ->
('a fetch_info -> 'a Js.Promise.t) ->
'a resource * 'a resource_actionsA resource fetched once, and again by refetch.
val create_resource_from :
?initial_value:'a ->
?name:string ->
?defer_stream:bool ->
?ssr_load_from:ssr_load_from ->
?storage:('a option -> 'a option accessor * 'a option setter) ->
?on_hydrated:('a option -> unit) ->
(unit -> 's option) ->
('s -> 'a fetch_info -> 'a Js.Promise.t) ->
'a resource * 'a resource_actionsA resource fetched from its source's value whenever it changes, and not while it is None. A source value of false is fetched as any other, as against Solid's, which skips it.
val read : 'a resource -> 'a optionThe value, tracked; None before the first. Reading an Errored resource raises its error, which an ErrorBoundary catches.
val loading : 'a resource -> boolval error : 'a resource -> exn optionval latest : 'a resource -> 'a optionThe last value, held while it is fetched again.
val mutate : 'a resource_actions -> 'a option -> unitSets the value without fetching.
val refetch : 'a resource_actions -> unitval map_array :
?fallback:(unit -> 'b) ->
(unit -> 'a array) ->
('a -> int accessor -> 'b) ->
'b array accessorMaps each item once, by identity, as For does: an item that stays keeps its result, and its index is tracked.
val index_array :
?fallback:(unit -> 'b) ->
(unit -> 'a array) ->
('a accessor -> int -> 'b) ->
'b array accessorMaps each index once, as Index does: the item at an index is tracked.
val observable : 'a accessor -> 'a observableval subscribe : 'a observable -> ('a -> unit) -> subscriptionval unsubscribe : subscription -> unitval from : (('a -> unit) -> unit -> unit) -> 'a option accessorfrom produce reads what produce sets: produce set starts it and gives what stops it, which runs when the owner is disposed.
val from_observable : 'a observable -> 'a option accessorAn id unique to this render, the same on the server and in the browser.
Children resolved to their elements, by children.
val children : (unit -> Jsx.content) -> resolved accessorchildren (fun () -> props_children ()) resolves a component's children once, so it can look at them without creating them again.
val to_array : resolved -> Jsx.element arrayval lazy_ : (unit -> 'props Jsx.component Js.Promise.t) -> 'props Jsx.componentA component loaded when it is first rendered, which suspends until it is.
Props whose each read takes the last part that has it, live: nothing is copied.
val omit : 'props -> string array -> 'props restomit props names is props without the props names, live, for a spread: Solid's splitProps, whose other half is props read through its getters. A component written by let%component has Props.omit, which takes its own props' names as a variant.
val others : 'props -> string array -> 'other restothers props names is props without names, its component's own props, live, for a spread on any element or component, as TSX passes a component's rest on: what is left is what its check admits besides them, its data- attributes, which every element and component takes. A component written by let%component has Props.others, which leaves out all of its own.