forked from cauios/cau_study_by_cauios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExploreApi.swift
33 lines (29 loc) · 961 Bytes
/
ExploreApi.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//
// ExploreApi.swift
// cau_study_ios
//
// Created by Davee on 2018. 4. 22..
// Copyright © 2018년 신형재. All rights reserved.
//
import Foundation
import FirebaseDatabase
class ExploreApi {
var REF_EXPLORE = Database.database().reference().child("explore")
func observeExplore(withId id: String, completion: @escaping (Post) -> Void) {
REF_EXPLORE.child(id).observe(.childAdded, with: {snapshot in
let key = snapshot.key
Api.Post.observePost(withId: key, completion: {
(post) in completion(post)
})
})
}
func observeExploreRemoved(withId id: String, completion: @escaping (Post) -> Void) {
REF_EXPLORE.child(id).observe(.childRemoved, with: {
snapshot in
let key = snapshot.key
Api.Post.observePost(withId: key, completion: {
(post) in completion(post)
})
})
}
}