Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@modelAction
setDone(done: boolean) {
this.done = done
}
@modelAction
setText(text: string) {
this.text = text
}
}
@model("todoSample/TodoList")
export class TodoList extends Model({
// in this case the default uses an arrow function to create the object since it is not a primitive
// and we need a different array for each model instane
todos: tProp(types.array(types.model(Todo)), () => []),
// if we didn't require runtime type checking
// todos: prop(() => [])
}) {
// standard mobx decorators (such as computed) can be used as usual, since props are observables
@computed
get pending() {
return this.todos.filter(t => !t.done)
}
@computed
get done() {
return this.todos.filter(t => t.done)
}
@modelAction