Skip to content

Instantly share code, notes, and snippets.

@ashour
Created April 23, 2019 15:09
Show Gist options
  • Save ashour/b6069f1d3caaf1528f80aee8fd9248c4 to your computer and use it in GitHub Desktop.
Save ashour/b6069f1d3caaf1528f80aee8fd9248c4 to your computer and use it in GitHub Desktop.
// ...
var productListener: Product.Listener?
fileprivate var products: [Product] = []
{
didSet
{
feedTableView.reloadData()
}
}
override func viewWillAppear(_ animated: Bool)
{
super.viewWillAppear(animated)
productListener = Product.listenToFeed
{
[unowned self] in self.products = $0
}
}
override func viewWillDisappear(_ animated: Bool)
{
super.viewWillDisappear(animated)
productListener?.remove()
}
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment