Closed Seobe95 closed 7 months ago
PR 날릴 때 체크 리스트
어떤 종류의 PR인가요?
Issue Number: #130
페이지네이션을 구현했습니다!
func pagenate(query: Query, limit: Int, lastDocument: QueryDocumentSnapshot?) async -> QuerySnapshot { do { var query: Query = query.order(by: "memoCreatedAt", descending: true) .limit(to: limit) if let lastDocument = lastDocument { query = query.start(afterDocument: lastDocument) } let querySnapshot = try await query.getDocuments() return querySnapshot } catch { fatalError("ERROR: querysnapshot \(error)") } }
func pagenate(userID: String) async { let fetchedMemos = await self.memoService.fetchMyMemos(userID: userID, lastDocument: self.lastDocument) { last in self.lastDocument = last } await MainActor.run { self.memoList += fetchedMemos } }
pagenate
query
limit
lastDocument
스크린샷
https://github.com/APP-iOS3rd/PJ3T2_Mymory/assets/79817557/a6897e8c-cb1f-47e8-b068-31a9d97eebc9
//예시 let testDatas: [TestData] = [.init(...),...]
무한스크롤 기능 여기저기 요긴하게 사용할 수 있겠네요! 고생하셨습니다 :)
PR 가이드라인
PR Checklist
PR 날릴 때 체크 리스트
PR Type
어떤 종류의 PR인가요?
연관되는 issue 정보를 알려주세요
Issue Number: #130
PR 설명하기
페이지네이션을 구현했습니다!
어떻게 작동하나요? code 기반으로 설명해주세요
pagenate
의query
는pagenate
를 사용할 때 지정한 쿼리들을 의미합니다. 이 쿼리들을 받아와서 최신순으로limit
개 만큼 firebase에서 가져옵니다.lastDocument
를 사용해서 몇번째 메모부터 불러올지를 정할 수 있습니다.lastDocument
를 선언하고, 이를 closure를 활용해 주입해주고 있습니다. 사용할 때마다 초기화가 되지 않도록 했습니다.보다 상세한 설명은 코드 주석으로 적어놓았습니다!
가능하다면 추가해주세요
변경 사항 스크린샷 혹은 화면 녹화
스크린샷
https://github.com/APP-iOS3rd/PJ3T2_Mymory/assets/79817557/a6897e8c-cb1f-47e8-b068-31a9d97eebc9
Test 여부
Test 정보
기타 언급해야 할 사항들