Skip to content

Instantly share code, notes, and snippets.

@nanotroy
Created May 30, 2019 21:39
Show Gist options
  • Save nanotroy/45ad3e50655ff2754a3ace291ed7a267 to your computer and use it in GitHub Desktop.
Save nanotroy/45ad3e50655ff2754a3ace291ed7a267 to your computer and use it in GitHub Desktop.
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