Skip to content

Instantly share code, notes, and snippets.

@Pacek
Last active April 8, 2017 12:37
Show Gist options
  • Save Pacek/110e9df43a3911a8589fb883dcab7977 to your computer and use it in GitHub Desktop.
Save Pacek/110e9df43a3911a8589fb883dcab7977 to your computer and use it in GitHub Desktop.
ReactiveKit+Realm
import ReactiveKit
import RealmSwift
extension ReactiveExtensions where Base: RealmCollection {
var changes: SafeSignal<Base> {
return SafeSignal<Base> { observer in
let realmToken = self.base.addNotificationBlock { changes in
switch changes {
case .initial(let new), .update(let new, _, _, _):
observer.next(new)
case .error:
break
}
}
return BlockDisposable {
realmToken.stop()
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment