RxJava هي مكتبة برمجة تفاعلية لتأليف برامج غير متزامنة وبرامج مستندة إلى الأحداث باستخدام تسلسلات قابلة للمراقبة.
تتيح لك مكتبة Places Rx تلقّي تسلسلات قابلة للمراقبة للأحداث غير المتزامنة في حزمة تطوير البرامج بالاستناد إلى بيانات خرائط Google للتطبيقات المتوافقة مع Android وPlaces SDK for Android، ما يتيح لك الاستفادة من المجموعة الغنية من ميزات RxJava.
تثبيت
لتثبيت مكتبة Places Rx في مشروع "خرائط Google"، اتّبِع الخطوات التالية:
أضِف الاعتماديات التالية إلى ملف
build.gradleعلى مستوى الوحدة:dependencies { // RxJava bindings for the Maps SDK implementation(libs.maps.rx) // RxJava bindings for the Places SDK implementation(libs.places.rx) // 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:20.0.0") implementation("com.google.android.libraries.places:places:5.3.0") implementation("io.reactivex.rxjava3:rxjava:3.1.12")
أعِد إنشاء مشروعك في "استوديو Android" لمزامنة هذه التغييرات.
مثال على الاستخدام
تلقّي Single والاشتراك فيه عند جلب تفاصيل المكان:
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}") } ) }
الخطوات التالية
- اطّلِع على صفحة مشروع Places Rx library على GitHub.
- اطّلِع على مرجع واجهة برمجة التطبيقات لمكتبة Places Rx.