Combine은 이벤트 처리 연산자를 결합하여 비동기 이벤트를 처리하는 프레임워크입니다. Combine은 이벤트 처리 코드를 중앙 집중화하여 코드를 더 쉽게 읽고 유지관리할 수 있도록 합니다.
GoogleMapsPlatformCombine 라이브러리는 iOS용 Maps SDK 및 iOS용 Places SDK에 Publishers를 반환하는 Swift 라이브러리로, 풍부한 Combine 기능 세트를 활용할 수 있습니다.
설치
시스템 요구사항 및 설치 안내는 GitHub의 GoogleMapsPlatformCombine 라이브러리 문서를 참고하세요.
사용 예
GoogleMapsPlatformCombine 라이브러리는 장소 API 호출에 Future 게시자를 반환하는 GMSPlacesClient 클래스에 대한 확장 프로그램을 제공합니다.
fetchPlace(id:, fields:, sessionToken:) -> Future<GMSPlace, Error> 확장 프로그램을 사용하여 장소 세부정보를 가져옵니다.
GMSPlacesClient.shared() .fetchPlace( id: "placeId", fields: [.placeID, .name, .phoneNumber] ) .sink { completion in print("Completion \(completion)") } receiveValue: { place in print("Got place \(place.name ?? "")") }
다음 단계
- Combine 라이브러리 GitHub 프로젝트 페이지를 참고하세요.