RxProperty


Source link: https://github.com/skedgo/RxProperty

RxProperty

RxJava binding APIs for observable fields and observable collections from the Data Binding Library

Usage

A main feature of this library is to provide some extension functions asObservable() to model the changes of observable fields and observable collections via 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<String>. 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:

class PersonViewModel {

val firstName = ObservableField<String>()
val lastName = ObservableField<String>()
val fullName = ObservableField<String>()
 init {

  Observable.combineLatest(

 firstName.asObservable(),

 lastName.asObservable(), {

 firstName, lastName ->

 if (firstName.isNullOrEmpty() && lastName.isNullOrEmpty()) {

return firstName

 
}
 else if (firstName.isNullOrEmpty()) {

return lastName

 
}
 else if (lastName.isNullOrEmpty()) {

return firstName

 
}
 else {

return "${
firstName
}
, ${
lastName
}
"

 
}

  
}
).subscribe {
 fullName.set(it) 
}

}
 
}

That is achieved because when we subscribe to an Observable created by asObservable(), the Observable will emit the current value of ObservableField<String> 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:

val onFullNameChanged = fullName.asObservable().skip(1)

As of now, the library only supports ObservableBoolean, ObservableField, and ObservableList 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.

Resources

A simple WYSIWYG Editor for Android based on Summernote.

Nibo is a collection of useful widgets and drop in UIs for interacting with Google Places API.

Just another custom Android Toast.

A fully "functional" and easy to use android utility library.

CosmoCalendar is a fully customizable calendar with a wide variety of features and displaying modes.

Simple Android library for permissions request.

Why NoPermission:

  • Not a framework. It's just one class
  • Never ask again feature
  • Automatic check whether the permission is granted or not (don't need to check api version)
  • Fragments support

How to use

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes