Skip to content

Commit

Permalink
feat(Example/Todo): refer ActionCreator
Browse files Browse the repository at this point in the history
  • Loading branch information
mattak committed Dec 27, 2016
1 parent b9841f6 commit fc48345
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@ void OnEnable()

void Dispatch(string text)
{
Unidux.Store.Dispatch(new TodoDuck.Action()
{
ActionType = TodoDuck.ActionType.ADD_TODO,
Todo = new Todo() {Text = text}
});

Unidux.Store.Dispatch(TodoDuck.ActionCreator.CreateTodo(text));
this.InputField.text = "";
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ void OnEnable()
this.GetComponent<Button>()
.OnClickAsObservable()
.TakeUntilDisable(this)
.Subscribe(_ => Unidux.Store.Dispatch(new TodoVisibilityDuck.Action()
{
ActionType = TodoVisibilityDuck.ActionType.SET_VISIBILITY,
Filter = Filter
}))
.Subscribe(_ => this.Dispatch())
.AddTo(this);
}

void Dispatch()
{
Unidux.Store.Dispatch(TodoVisibilityDuck.ActionCreator.SetVisibility(Filter));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,7 @@ void OnEnable()

void Dispatch(bool value)
{
Unidux.Store.Dispatch(new TodoDuck.Action()
{
ActionType = TodoDuck.ActionType.TOGGLE_TODO,
Todo =
new Todo()
{
Id = Todo.Id,
Text = Todo.Text,
Completed = value
},
});
Unidux.Store.Dispatch(TodoDuck.ActionCreator.ToggleTodo(this.Todo, value));
}
}
}

0 comments on commit fc48345

Please sign in to comment.