Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { run } from '@composi/core'
- const program = {
- // Handle initialization by setting state
- // and running a subscription (effect) at startup.
- init() {
- return [state, effect]
- },
- // The view handles state and provides the UI with
- // a send function for dispatching messages to Update.
- view(state, send) {
- // Render a component:
- return render(Component(state, send), document.body)
- },
- update(msg, state) {
- // action based on message type:
- if (msg.type === 'add-item') {
- state.push(msg.data)
- }
- // When done, return state and
- // optionally run an effect:
- return [state, effect]
- }
- }
- // Run the program:
- run(program)
Add Comment
Please, Sign In to add comment