How to create a function that inserts data into a block
<p>First can someone help me come up with a better title? I just don't know the correct terminology on this one.</p>

<p>Here is my code,</p>

<pre><code>func loadPublicFeed() {

    ref = FIRDatabase.database().reference()
    ref.child("brackets").observeSingleEvent(of: FIRDataEventType.value, with: { (snapshot) in
        if let bracketsSnapshot = snapshot.children.allObjects as? [FIRDataSnapshot] {
            for brackets in bracketsSnapshot {
                if let bracketsDict = brackets.value as? Dictionary &lt;String, Any&gt; {
                   let key = brackets.key as String
                    let post = BracketsPublicFeed(postKey:key, postData: bracketsDict)
                    self.posts.insert(post, at: 0)
                }
            }
        }
        self.stopRefresher()
        self.collectionView.reloadData()
        self.watchlistClicked = false

    })
}
</code></pre>

<p>download data then do stuff. I want to take this function refactor it so I can just call the refactored function and add these</p>

<pre><code>self.stopRefresher()
self.collectionView.reloadData()
self.watchlistClicked = false
</code></pre>

<p>into it.</p>

<p>It might look something like this,</p>

<pre><code>func loadFeedTest() {
    fetchTest.loadPublicFeed(collectionView: self.collectionView, completionHandler: { () -&gt; Void in
        self.stopRefresher()
        self.collectionView.reloadData()
        self.watchlistClicked = false
      })
</code></pre>

<p>I have tried using a <code>completionHandler</code> something like <code>func loadPublicFeed(completionHandler: () -&gt; Void)</code> then the code. I have done many variations of this. I feel like I might be on the right path but I just can't nail this down.</p>