Skip to content

Rootless

Bindings for @solid-primitives/rootless.

RootPoolFactory

Type: delegate

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

The factory for createRootPool, called whenever the pool creates a new root.

ParamDesc
argAn accessor of the argument passed to the pool function.
activeAn accessor of whether the root is in use. When false, the root is waiting in the pool to be reused.
disposeDisposes the root, so it is not reused.

Bindings

MemberDesc
createSubRootCreates a reactive sub-root that is disposed automatically with its owner. Cleaning up any of the owners disposes it. owners defaults to getOwner().
createCallbackWraps a callback so it runs under the given owner.
createDisposableLike createSubRoot, but returns the dispose function.
createSingletonRootCreates one shared root, set up on first use and shared by every caller.
createHydratableSingletonRootcreateSingletonRoot that is safe to hydrate.
createRootPoolCreates a pool of roots to reuse. Useful for components that mount and unmount often.

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 arg. limit is the pool size, and defaults to 100.

Bindings
[<AutoOpen; Erase>]
type Rootless =
    [<ImportMember(Spec.path)>]
    static member createSubRoot<'T>(fn: DisposeCallback -> 'T, [<ParamArray>] owners: obj): 'T = jsNative
    [<ImportMember(Spec.path)>]
    static member createCallback<'T>(callback: 'T, ?owner: obj): 'T = jsNative
    [<ImportMember(Spec.path)>]
    static member createDisposable(fn: DisposeCallback -> unit, [<ParamArray>] owners: obj): DisposeCallback = jsNative
    [<ImportMember(Spec.path)>]
    static member createSingletonRoot<'T>(
        factory: DisposeCallback -> 'T,
        ?detachedOwner: obj
        ): Accessor<'T> = jsNative
    [<ImportMember(Spec.path)>]
    static member createHydratableSingletonRoot<'T>(factory: DisposeCallback -> 'T): Accessor<'T> = jsNative
    [<ImportMember(Spec.path); ParamObject(1)>]
    static member createRootPool<'Arg, 'Result>(
            factory: Rootless.RootPoolFactory<'Arg, 'Result>,
            limit: int
        ): 'Arg -> 'Result = jsNative
    [<ImportMember(Spec.path)>]
    static member createRootPool<'Arg, 'Result>(
            factory: Rootless.RootPoolFactory<'Arg, 'Result>
        ): 'Arg -> 'Result = jsNative
Edit this page