title: How to create custom signal in ReactiveCocoa 4?
body: <p>I have the following setup, a <code>GridView</code> that consists of <code>GridViewCell</code>s.</p>
  
  <h3>GridView</h3>
  
  <pre><code>class GridView : UIView {
  
      var gridViewCells: [GridViewCell] = []
      let tapHandler: Position -&gt; ()
  
      init(frame: CGRect, tapHandler: Position -&gt; ()) {
          self.tapHandler = tapHandler
          super.init(frame: frame)
          self.gridViewCells = createCells(self)
          addCellsToView(self.gridViewCells)
      }
  
      func addCellsToView(cells: [GridViewCell]) {
          for cell in cells {
              self.addSubview(cell)
          }
      }
  }
  </code></pre>
  
  <h3>GridViewCell</h3>
  
  <pre><code>class GridViewCell: UIImageView {
  
      let position: Position
      let tapHandler: Position -&gt; ()
  
      init(frame: CGRect, position: Position, tapHandler: Position -&gt; ()) {
          self.position = position
          self.tapHandler = tapHandler
          super.init(frame: frame)
      }
  
      func handleTap(sender: UITapGestureRecognizer) {
          self.tapHandler(self.position)
      }    
  }
  </code></pre>
  
  <p>Note that I omitted some less relevant parts of the code, just know that when creating the cells in <code>createCells()</code>, every cell gets a <code>UITapGestureRecognizer</code> that targets <code>handleTap:</code>, I am also using:</p>
  
  <pre><code>typealias Position = (Int, Int)
  </code></pre>
  
  <p>So, as you can see, whenever a <code>GridView</code> gets instantiated, it gets passed a callback function <code>tapHandler: Position -&gt; ()</code> that ultimately gets called by the cell when a cell is tapped by the user.</p>
  
  <p>Now, I want to turn the tap events into a RAC <code>Signal</code>. I have no clue how to approach this, as I am very new to RAC. Thanks to <a href="http://blog.scottlogic.com/2015/04/24/first-look-reactive-cocoa-3.html" rel="nofollow">Colin Eberhardts blog articles</a>, I managed to get a basic understanding of the building blocks and implement a custom signal like so:</p>
  
  <pre><code>func createSignal() -&gt; Signal&lt;String, NoError&gt; {
      var count = 0
      return Signal {
          sink in
          NSTimer.schedule(repeatInterval: 1.0) { timer in
              sink.sendNext("tick #\(count++)")
          }
          return nil
      }
  }
  </code></pre>
  
  <p>I now basically want a similar behaviour only that the emitted events aren't triggered by a <code>NSTimer</code>, but rather by the <code>handleTap()</code> function. </p>