Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ReactiveCocoa Swift Extension
// 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
You can’t perform that action at this time.