Skip to content

Commit

Permalink
Update reducer init state
Browse files Browse the repository at this point in the history
  • Loading branch information
onevcat committed Jul 13, 2017
1 parent a6d807f commit 316e4c4
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions ToDoDemo/TableViewController.swift
Expand Up @@ -81,16 +81,14 @@ class TableViewController: UITableViewController {
}
}

guard let previousState = previousState else { return }

if previousState.dataSource.todos != state.dataSource.todos {
if previousState == nil || previousState!.dataSource.todos != state.dataSource.todos {
let dataSource = state.dataSource
tableView.dataSource = dataSource
tableView.reloadData()
title = "TODO - (\(dataSource.todos.count))"
}

if (previousState.text != state.text) {
if previousState == nil || previousState!.text != state.text {
let isItemLengthEnough = state.text.count >= 3
navigationItem.rightBarButtonItem?.isEnabled = isItemLengthEnough

Expand Down

0 comments on commit 316e4c4

Please sign in to comment.