Handle Asynchronous Operations
In this section, you will learn how to work with asynchronous operations in app-compose
.
Both enable
and start
can be async functions, which is useful when you need to perform operations like fetching data or checking system readiness.
Example
const isChefAvailable = async () => { await new Promise((resolve) => setTimeout(resolve, 1000)); return true;};
const sharpenKnives = async () => { await new Promise((resolve) => setTimeout(resolve, 2000)); return { knives: ['little', 'big'] };};
const chef = createContainer({ id: 'John Doe', domain: 'italian-chef', enable: isChefAvailable, start: async () => { const data = await sharpenKnives(); return { api: data }; },});