Created
July 19, 2015 13:23
-
-
Save josafafilho/a2d5ff17c2c4228d5115 to your computer and use it in GitHub Desktop.
ReactiveCocoa Swift Extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ReactiveCocoaExtension.swift | |
// | |
// Simple ReactiveCocoa Swift extensions using generics | |
// Created by josafafilho<josafafilho15@gmail.com> on 7/19/15. | |
import Foundation | |
import ReactiveCocoa | |
extension RACSignal { | |
func subscribeNextAs<T>(nextClosure:(T) -> ()) -> () { | |
self.subscribeNext { | |
(next: AnyObject!) -> () in | |
let nextAsT = next as! T | |
nextClosure(nextAsT) | |
} | |
} | |
func filterAs<T>(filterClosure:(T) -> Bool) -> RACSignal { | |
return self.filter { filter -> Bool in | |
let filterAsT = filter as! T | |
return filterClosure(filterAsT) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment