Skip to main content

API

work in progress

Docs

Tokens

Containers

Containers are an important unit. If you replace them, users will be notified. In React it happens automatically

Events

const kitchenApp = new RootContainer((ctx) => ({
// you can use tokens (`oven`, `kitchen`) here and later on
oven: async () => ovenContainer(),
kitchen: async () => kitchenContainer(await ctx.oven()),
}))

kitchenApp.on("containerCreated", (event) => {
console.log(`event: 'containerCreated' ~~> token: '${event.key}'`)
// `event.container` is also avaliable here
})

kitchenApp.on("containerRequested", (event) => {
console.log(`event: 'containerRequested' ~~> token: '${event.key}' `)
})

kitchenApp.on("containerRemoved", (event) => {
console.log(`event: 'containerRemoved' ~~> token: '${event.key}' `)
})

await kitchenApp.containers.kitchen

// event: 'containerRequested' ~~> token: 'kitchen'
// event: 'containerRequested' ~~> token: 'oven'
// event: 'containerCreated' ~~> token: 'oven'
// event: 'containerCreated' ~~> token: 'kitchen'

// Notice how oven was created before kitchen.
// This is because kitcen depends on oven

API documentation JS / TS

makeRoot Setting app root

import { makeRoot } from "../../library.root-container"
export function getMainMockAppContainer() {
return makeRoot().add({ kitchen: () => new Kitchen(/* deps */) })
}

containers getter

let appRoot = getMainPizzaAppContainer()
let kitchen = await appRoot.containers.kitchen
kitchen.oven.pizzaCapacity // 4

getContainerSet

getContainerSetNew

upsert

When containers are updated React is updated too via hooks