Created
May 30, 2019 21:39
-
-
Save nanotroy/45ad3e50655ff2754a3ace291ed7a267 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { StreamBox } from '@crui/reactive/rx/box'; | |
import { StreamList } from '@crui/reactive/rx/list'; | |
export type Todo = { | |
text: string, | |
} | |
export type TodoList = StreamList<Todo> | |
export class TodoStore { | |
public readonly input: StreamBox<string> | |
public readonly todos: TodoList | |
constructor() { | |
this.input = new StreamBox('') | |
this.todos = new StreamList<Todo>([]) | |
} | |
addTodo(todo: string): void { | |
this.todos.push({ | |
text: todo, | |
}) | |
} | |
dispose() { | |
this.input.destroy() | |
this.todos.destroy() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment