RxJava लाइब्रेरी

RxJava एक रिऐक्टिव प्रोग्रामिंग लाइब्रेरी है. इसकी मदद से, एसिंक्रोनस और इवेंट पर आधारित प्रोग्राम बनाए जाते हैं मॉनिटर किए जा सकने वाले क्रमों का इस्तेमाल किया जाता है.

Places Rx लाइब्रेरी की मदद से, Android के लिए Maps SDK पर एसिंक्रोनस इवेंट के लिए मॉनिटर किए जा सकने वाले क्रम पाए जा सकते हैं और Android के लिए Places SDK टूल की जानकारी जोड़ी है. इससे आपको RxJava की बेहतरीन सुविधाओं का फ़ायदा मिल सकता है.

इंस्टॉल करना

अपने Google Maps प्रोजेक्ट में Places Rx लाइब्रेरी इंस्टॉल करने के लिए:

  1. अपने मॉड्यूल-लेवल की build.gradle फ़ाइल में, ये डिपेंडेंसी जोड़ें:

    dependencies {
        // RxJava bindings for the Maps SDK
        implementation("com.google.maps.android:maps-rx:1.0.0")
    
        // RxJava bindings for the Places SDK
        implementation("com.google.maps.android:places-rx:1.0.0")
    
        // It is recommended to also include the latest Maps SDK, Places SDK and RxJava so you
        // have the latest features and bug fixes.
        implementation("com.google.android.gms:play-services-maps:19.0.0")
        implementation("com.google.android.libraries.places:places:4.1.0")
        implementation("io.reactivex.rxjava3:rxjava:3.1.8")
  2. इन बदलावों को सिंक करने के लिए, Android Studio में अपना प्रोजेक्ट फिर से बनाएं.

इस्तेमाल का उदाहरण

नीचे दिए गए उदाहरण में बताया गया है कि सिंगल, और इसकी सदस्यता लें, तब जगह की जानकारी फ़ेच करें:

  placesClient.fetchPlace(
    placeId = "thePlaceId",
    placeFields = listOf(Place.Field.ID, Place.Field.NAME, Place.Field.ADDRESS),
    actions = {}
  ).subscribe(
    { response ->
      Log.d("PlacesRx", "Successfully got place ${response.place.id}")
    },
    { error ->
      Log.e("PlacesRx", "Could not get place: ${error.message}")
    }
  )
}

आगे क्या करना है