Skip to main content

EcosystemConfig

The config object passed to the createEcosystem() factory.

Definition

interface EcosystemConfig<
Context extends Record<string, any> | undefined = any
> {
atomDefaults?: {
ttl?: number
}
complexParams?: boolean
context?: Context
destroyOnUnmount?: boolean
flags?: string[]
id?: string
onReady?: (
ecosystem: Ecosystem<Context>,
prevContext?: Context
) => MaybeCleanup
overrides?: AnyAtomTemplate[]
ssr?: boolean
}

All fields are optional. It is recommended to at least pass an id.

complexParams

A boolean. Default false. Whether "complex" atom and selector params should be allowed.

context

An object. The initial context for the ecosystem.

atomDefaults

An object. This object currently accepts a single optional property - ttl. If specified, this ttl will be used as the ttl for all atoms in the ecosystem that don't specify one.

destroyOnUnmount

A boolean. Defaults to false for ecosystems created via createEcosystem(). Defaults to true for ecosystems created automatically by rendering an <EcosystemProvider>.

Whether the ecosystem should destroy itself when its last <EcosystemProvider> unmounts. Can be useful for testing.

flags

An array of strings. Will be set as the ecosystem's flags.

id

A string. Identifies the ecosystem in the internal store and in dev tools. If no id is specified when creating the ecosystem, one will be generated randomly.

onReady

A function. Will be set as the ecosystem's onReady function.

overrides

An array of atom templates. Will be mapped into the ecosystem's overrides object.

Used for Dependency Injection.

ssr

A boolean. Default false. Turns on SSR mode for the entire ecosystem.

See the SSR guide.

See Also