Last active
August 11, 2017 09:49
-
-
Save phucnm/84fe9b9f9663c74f74416b90dbc88904 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 getPosts() -> Observable<[Post]> { | |
| let postRef = Database.database().reference() | |
| .child("posts") | |
| return postRef.rx_observeSingleEvent(of: .value) | |
| .map { Mapper<Post>().mapArray(snapshot: $0) } | |
| } | |
| getPosts().subscribe(onNext: { posts in | |
| //show the data or do whatever you want | |
| }, onError: { error in | |
| //show an alert | |
| }).disposed(by: disposeBag) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment