Skip to content

Rootless

Bindings for @solid-primitives/rootless.

let createSubRoot<'T>(fn: DisposeCallback -> 'T, [<ParamArray>] owners: obj): 'T
let createCallback<'T>(callback: 'T, ?owner: obj): 'T
let createDisposable(fn: DisposeCallback -> unit, [<ParamArray>] owners: obj): DisposeCallback
let createSingletonRoot<'T>(factory: DisposeCallback -> 'T, ?detachedOwner: obj): Accessor<'T>
let createHydratableSingletonRoot<'T>(factory: DisposeCallback -> 'T): Accessor<'T>
let createRootPool<'Arg, 'Result>(factory: RootPoolFactory<'Arg, 'Result>, ?limit: int): 'Arg -> 'Result
MemberDesc
createSubRootA reactive sub-root, disposed when any of owners is cleaned up. owners defaults to getOwner().
createCallbackWraps a callback so it runs under the given owner.
createDisposableLike createSubRoot, but returns the dispose function.
createSingletonRootOne shared root, set up on first use and shared by every caller.
createHydratableSingletonRootcreateSingletonRoot that is safe to hydrate.
createRootPoolA pool of roots to reuse, for components that mount and unmount often.

createRootPool

Call the function createRootPool returns to get a root. A root that is cleaned up goes back to the pool instead of being disposed, and the next call reuses it with the new argument. limit is the pool size, and defaults to 100.

type RootPoolFactory<'Arg, 'Result> =
    delegate of arg: Accessor<'Arg> * active: Accessor<bool> * dispose: DisposeCallback -> 'Result

The pool calls the factory whenever it creates a new root. arg reads the argument of the current use, active is false while the root waits in the pool, and dispose removes the root from the pool for good.

Edit this page