RxActions


Source link: https://github.com/pakoito/RxActions

RxActions

RxActions is a library to smooth RxJava usage by functionally composing actions.

For the RxJava 2.X version please go to RxConsumers.

Rationale

Sometimes you have to describe side effects in your Observable chain, by means of doOnNext, doOnError, or even in the subscription. Writing several of those operators may incur on minimal performance penalties, and make the chain more verbose. RxActions allows you to combine those actions sequentially.

One acknowledged critique is that the composition can be done inlined and imperatively instead by using a lambda. That's not available on Java 1.6 versions without 3rd party tools, making it effectively more verbose.

Usage

RxActions comes as lazily evaluated ActionN and its main use case is for doOnNext, doOnError, and subscribe operators. Please note subscribe comes in several flavours that accept ActionN for better composability.

Log correct server response, cache it, and display on UI:

getApi().requestListFromServer()

.subscribe(RxActions.act(logElement(), cacheElements(), getUi.displayElements()));
 

Log an error to console, then display UI message:

getApi().requestListFromServer()

.subscribe(/* ... */,

  RxActions.act(logError(), getUi().displayErrorMessage()));
 

Log error, clear cache, and display a message before applying an error correction operator:

getApi().storeInDatabase()

.doOnError(RxActions.act(logError(), getUi().displayErrorMessage(), clearCache()))

.onErrorReturn(Collections.emptyList())

.subscribe(/* ... */);
 

Distribution

Add as a dependency to your build.gradle

repositories {

  ...
  maven {
 url "https://jitpack.io" 
}

  ... 
}
  dependencies {

  ...
  compile 'com.github.pakoito:RxActions:1.0.+'
  ... 
}
 

or to your pom.xml

<repositories>
  <repository>

<id>jitpack.io</id>

<url>https://jitpack.io</url>
  </repository> </repositories>  <dependency>
  <groupId>com.github.pakoito</groupId>
  <artifactId>RxActions</artifactId>
  <version>1.0.0</version> </dependency> 

License

Copyright (c) pakoito 2015

The Apache Software License, Version 2.0

See LICENSE.md

Resources

An easy to use Android library with a fluent interface to integrate voice interaction into your Application.

Android Library that checks for updates on Google Play, GitHub or Amazon. This library notifies your apps' updates by showing a Material dialog, Snackbar or notification.

PaperParcel is an annotation processor that automatically generates type-safe Parcelable wrappers for Kotlin and Java.

An iOS Passbook-like highly customisable stack of cards implementation for Android.

Sharp is a Scalable Vector Graphics (SVG) implementation for Android. It facilitates loading vector graphics as SharpDrawables, and can effectively be used wherever a conventional image would be displayed, whether it be as a background, ImageView source, inside a StateListDrawable or used as composites in a TextView.

Standard ViewGroups which responds to nested scrolls to create drag-dismissable layouts. Original code taken from Plaid and made backwards compatible.

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