Last active
April 8, 2017 12:37
-
-
Save Pacek/110e9df43a3911a8589fb883dcab7977 to your computer and use it in GitHub Desktop.
ReactiveKit+Realm
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
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