Skip to main content

createEcosystem

import { createEcosystem } from '@zedux/react'

Creates an atom ecosystem.

Examples

import { createEcosystem } from '@zedux/react'

const rootEcosystem = createEcosystem({ id: 'root' })

const withOverrides = createEcosystem({
id: 'withOverrides',
overrides: [atomA, atomB],
})

const withOnReadyFn = createEcosystem({
id: 'withOnReadyFn',
onReady: ecosystem => {
// `onReady` is passed a reference to the ecosystem
ecosystem.getInstance(myAtom) // preload myAtom
},
})

Signature

createEcosystem = (config?) => Ecosystem
config

Optional. An EcosystemConfig object.

While all fields are optional, it's recommended to at least pass an id.

Returns

An Ecosystem instance, configured with the passed config.

See Also