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
- Simplified
- TypeScript
createEcosystem = (config?) => Ecosystem
declare const createEcosystem: <
Context extends Record<string, any> | undefined = any
>(
config?: EcosystemConfig<Context>
) => Ecosystem<any> | Ecosystem<Context>
Optional. An EcosystemConfig object.
While all fields are optional, it's recommended to at least pass an id
.
An Ecosystem instance, configured with the passed config
.