{"id":20227941,"url":"https://github.com/skedgo/rxproperty","last_synced_at":"2025-04-10T17:25:41.458Z","repository":{"id":147410784,"uuid":"84809238","full_name":"skedgo/RxProperty","owner":"skedgo","description":"RxJava binding APIs for observable fields and observable collections from the Data Binding Library","archived":false,"fork":false,"pushed_at":"2019-06-10T13:17:39.000Z","size":71,"stargazers_count":18,"open_issues_count":0,"forks_count":1,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-24T15:04:32.840Z","etag":null,"topics":["android","data-binding","kotlin","rxjava"],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skedgo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-13T09:41:50.000Z","updated_at":"2024-10-22T18:43:24.000Z","dependencies_parsed_at":"2023-05-22T12:30:51.902Z","dependency_job_id":null,"html_url":"https://github.com/skedgo/RxProperty","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skedgo%2FRxProperty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skedgo%2FRxProperty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skedgo%2FRxProperty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skedgo%2FRxProperty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skedgo","download_url":"https://codeload.github.com/skedgo/RxProperty/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248261968,"owners_count":21074229,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","data-binding","kotlin","rxjava"],"created_at":"2024-11-14T07:27:27.597Z","updated_at":"2025-04-10T17:25:41.449Z","avatar_url":"https://github.com/skedgo.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RxProperty\n[![](https://jitpack.io/v/skedgo/RxProperty.svg)](https://jitpack.io/#skedgo/RxProperty) [![Build Status](https://travis-ci.org/skedgo/RxProperty.svg?branch=master)](https://travis-ci.org/skedgo/RxProperty) \u003ca href=\"http://www.methodscount.com/?lib=com.github.skedgo%3ARxProperty%3Av1.3\"\u003e\u003cimg src=\"https://img.shields.io/badge/Methods and size-47 | 13 KB-e91e63.svg\"/\u003e\u003c/a\u003e\n\nRxJava binding APIs for observable fields and observable collections from the Data Binding Library\n\n## Usage\nA main feature of this library is to provide some extension functions `asObservable()` to model the changes of observable fields and observable collections via [RxJava](https://github.com/ReactiveX/RxJava)'s `Observable`. The library is specially helpful for the cases of implementing dependent properties. For example, assume that we have a `PersonViewModel` that specifies `firstName` and `lastName`. Both are represented by `ObservableField\u003cString\u003e`. There is another `fullName` that is computed based on `firstName` and `lastName`. Whenever one of the 2 properties is updated, `fullName` should be updated accordingly. By utilizing `asObservable()` functions, an implementation can be:\n\n```kotlin\nclass PersonViewModel {\n  val firstName = ObservableField\u003cString\u003e()\n  val lastName = ObservableField\u003cString\u003e()\n  val fullName = ObservableField\u003cString\u003e()\n\n  init {\n    Observable.combineLatest(\n      firstName.asObservable(),\n      lastName.asObservable(), {\n      firstName, lastName -\u003e\n      if (firstName.isNullOrEmpty() \u0026\u0026 lastName.isNullOrEmpty()) {\n        return firstName\n      } else if (firstName.isNullOrEmpty()) {\n        return lastName\n      } else if (lastName.isNullOrEmpty()) {\n        return firstName\n      } else {\n        return \"${firstName}, ${lastName}\"\n      }\n    }).subscribe { fullName.set(it) }\n  }\n}\n```\n\nThat is achieved because when we subscribe to an `Observable` created by `asObservable()`, the `Observable` will emit the current value of `ObservableField\u003cString\u003e` and also emit any future changes. But what if we are only interested in observing future changes without the current value? Easy, just `skip(1)`, for instance:\n\n```kotlin\nval onFullNameChanged = fullName.asObservable().skip(1)\n```\n\nAs of now, the library only supports [`ObservableBoolean`](https://developer.android.com/reference/android/databinding/ObservableBoolean.html), [`ObservableField`](https://developer.android.com/reference/android/databinding/ObservableField.html), and [`ObservableList`](https://developer.android.com/reference/android/databinding/ObservableList.html) due to our current need. In the future, we may add more `asObservable()` functions for other kinds. That said, we welcome any external contribution. Pull requests are very highly appreciated.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskedgo%2Frxproperty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskedgo%2Frxproperty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskedgo%2Frxproperty/lists"}