Skip to content

Instantly share code, notes, and snippets.

@phucnm
Created August 11, 2017 16:13
Show Gist options
  • Select an option

  • Save phucnm/6847c56db2daa806e30a03daa45227dc to your computer and use it in GitHub Desktop.

Select an option

Save phucnm/6847c56db2daa806e30a03daa45227dc to your computer and use it in GitHub Desktop.
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