Created
August 11, 2017 16:13
-
-
Save phucnm/6847c56db2daa806e30a03daa45227dc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| func getPost() -> Observable<Post> { | |
| let postRef = Database.database().reference() | |
| .child("posts") | |
| return postRef.rx_observeEvent(event: .childAdded) | |
| .map { Post(snapshot: $0) } | |
| .unwrap() | |
| } | |
| getPost() | |
| //It will emit an Error Event in case timed out | |
| .timeout(10, scheduler: MainScheduler.instance) | |
| //Filter the result in one line | |
| .filter { $0.title?.contains("QueryString") ?? false } | |
| .subscribe() | |
| .disposed(by: disposeBag) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment