Concepts

Composition root

Try the free JavaScript compiler

Assemble dependencies once near the entry point; domain functions do not import the composition root.

Formal Syntax & Structure

javascript syntaxjavascript
createApp({ calculate, render })

Working Example

Example Snippetjavascript
(async () => {const calculate=n=>n*2;const messages=[];const render=n=>messages.push(`Total: ${n}`);function app(input){render(calculate(input));}app(5);console.log(JSON.stringify(messages));})()
JavaScript Reference