Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difficulty decoupling PersonViewController from Firebase calls #1

Open
kelvinlauKL opened this issue Oct 20, 2016 · 0 comments
Open

Comments

@kelvinlauKL
Copy link
Owner

This demo tries to isolate the Firebase calls in the Server namespace, however a Firebase call is done in PersonViewController:

override func viewDidLoad() {
  super.viewDidLoad()

  let personRef = FIRDatabase.database().reference().child("people")
  personRef.observe(.childAdded, with: { snapshot in
    guard let personDict = snapshot.value as? [String: Any] else { return print("couldn't cast") }
    let person = Person(dictionary: personDict)
    self.people.append(person)
    self.tableView.insertRows(at: [IndexPath(row: self.people.count - 1, section: 0)], with: .automatic)
  })
}

Ideally, you'd want this call to reside in the Server enum.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant