Guide / JavaScript /

Create an observer

Once we have register our state the next step is create an observer that listen for mutations.

const observer = dop.createObserver(mutations => {
    // This will be executed after the push()
    console.log(state.todos[0].text) // "Finish documentation"
})
observer.observe(state.todos, 'length')

state.todos.push({
    text: "Finish documentation",
    completed: false
})

For a more detailed documentation have a look createObserver

Next step

Actions