RxPartialApplication


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

RxPartialApplication

RxPartialApplication is a library to allow partial application on RxJava function primitives.

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

Usage

RxPartialApplication contains two classes, RxPartialAction and RxPartialFunc. Each contains a set of apply() (apply parameters from left to right) and applyEnd() (apply parameters from right to left) methods to do partial application from any ActionN and FuncN to any type of a lower arity. For example, you can partially apply a Func6 object with 3 prefilled parameters to obtain a Func3 object to be reused.

Function to multiply numbers by 100:

Func1<Integer, Integer> multiplyBy100 = RxPartialFunc.apply((int first, int second) -> {
 return first * second; 
}
, 100);
 int result = multiplyBy100.call(5);
 // result == 500

Single parameter applicator:

Action1<String> salutator = RxPartialAction.apply(applicator(), (String parameter) -> {
 System.out.println("Hello, " + parameter);
 
}
 );
 salutator.call("pakoito");
 // prints "Hello, pakoito" Action1<Integer> duplicator = RxPartialFunc.apply(applicator(), (int parameter) -> {
 System.out.println("Double of parameter is " + 2 * parameter);
 
}
 );
 duplicator.call(2);
 // prints "Double of parameter is 4"  ...  public static <T> Action2<Action1<T>, T> applicator() {

  return (Action1<T> action, T parameter) -> {
 action.call(parameter);
 
}
; 
}

Filter only myself:

Func1<Object, Boolean> isMe = RxPartialFunc.apply(equalsFilter(), myUser);
 updatesFromDatabaseObservable().filter(isMe).map(toUser()).subscribe(/* ... */);
  ...  public static <T, U> Func2<T, U, Boolean> equalsFilter() {

  return (T first, U second) -> {
 return first.equals(second);
 
}
; 
}

You can also partially apply from the last parameter using applyEnd()

Func1<String, Observable<String>>> requestForUrl =

 RxPartialFunc.applyEnd(this::doNetworkRequest(), localDataStorage, ServerInfo.default(), RetrofitRequest.getInstance());
  requestForUrl.call("http://www.mycompany.com/api/users").subscribe(/* ... */);
  Observable<String> doNetworkRequest(String url, DataStorage storage, ServerInformation server, HttpClient client){

... 
}

Distribution

Add as a dependency to your build.gradle

repositories {

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

  ... 
}

dependencies {

  ...
  compile 'com.github.pakoito:RxPartialApplication:1.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>RxPartialApplication</artifactId>
  <version>1.1.0</version> </dependency>

License

Copyright (c) pakoito 2016

The Apache Software License, Version 2.0

See LICENSE.md

Resources

This library can be used to set advanced settings for wifi such as manual proxy and static ip configurations through your app. This code works in Android 5.0, it also works in 6.0 but you cannot update a network that you have not created yourself (due to android new rules).

Simple view to show a kanji from it's SVG representation and animate the drawing.

This is an automatic scrolling view pager slider with circular scrolling which gives you functionality of adding images and adding description of your images along with the pager indicator.

A network abstraction layer over Volley, written in Kotlin and inspired by Moya for Swift.

Animated Pencil Action view for Android.

Markwon is a library for Android that renders markdown as system-native Spannables. It gives ability to display markdown in all TextView widgets (TextView, Button, Switch, CheckBox, etc), Notifications, Toasts, etc. No WebView is required. Library provides reasonable defaults for display style of markdown but also gives all the means to tweak the appearance if desired. All markdown features are supported (including limited support for inlined HTML code, markdown tables and images).

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