Skip to content

Share Data Between Containers

In this section, you will learn how to share data between containers in app-compose.

Both enable and start can receive data from other containers. This is useful when one container depends on information from another.

Example

const ingredients = createContainer({
id: 'pizza-base',
domain: 'kitchen',
start: () => ({ api: { available: ['dough', 'sauce', 'cheese'] } }),
});
const chef = createContainer({
id: 'John Doe',
domain: 'italian-chef',
dependencies: [ingredients],
enable: (api) => api.ingredients.available.includes('cheese'),
start: (api) => {
console.log(`Making pizza with: ${api.ingredients.available.join(', ')}`);
return { api: { dish: 'pizza' } };
},
});