Advertisement
Guest User

Untitled

a guest
Apr 29th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import { StoreBase, AutoSubscribeStore, autoSubscribe } from 'resub'
  2.  
  3. @AutoSubscribeStore
  4. class TodosStore extends StoreBase {
  5. private _todos: string[] = ['hello','world']
  6. private _textInputValue: string = ''
  7.  
  8. updateTextInputValue(value: string) {
  9. this._textInputValue = value;
  10. this.trigger()
  11. }
  12.  
  13. addTodo() {
  14. if(this._textInputValue === '') return
  15. this._todos = [...this._todos, this._textInputValue]
  16. this._textInputValue = ''
  17. this.trigger()
  18. }
  19.  
  20. @autoSubscribe
  21. getTodos() {
  22. return this._todos
  23. }
  24.  
  25. @autoSubscribe
  26. getTextInputValue() {
  27. return this._textInputValue
  28. }
  29. }
  30.  
  31. export = new TodosStore()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement