Introducing ReactiveBus

Today, I’ve released my another tiny project. It’s a very simple implementation of Event Bus with RxJava 2 under the hood. This library is compatible with Java 1.7 or higher. I didn’t use Java 1.8 or 1.9 because I wanted to make it compatible with Android apps. You can use it as follows: Bus bus = ReactiveBus.create(); Disposable observer = bus.receive().subscribe(new Consumer<Event>() { @Override public void accept(Event event) { // handle event here } }); Once, we created Event Bus object and our observer (or more precisely: disposable subscriber), we can start sending events: ...

March 11, 2018 · 2 min · 259 words · Piotr Wittchen

DroidCon Poland 2017 - Is your app really connected?

Yesterday, I gave a presentation about connectivity in the Android apps during the DroidCon Poland 2017 Conference in Kraków. Below, you can see slides from this presentation. View slides on SpeakerDeck There’s also tweet related to this presentation from DroidCon Kraków: Piotr Wittchen tells us about how we can we keep the track of network 🌎 or Internet connectivity changes in our app 📱🆘🙂 pic.twitter.com/7YGGzNJeb2 — droidcon Kraków (@droidconkr) December 2, 2017 I hope, you enjoyed it. Any kind of feedback is welcome (in the comments below this article or via e-mail). Don’t forget to check ReactiveNetwork library I mentioned during the presentation.

December 2, 2017 · 1 min · 103 words · Piotr Wittchen

Simple reactive HTTP client and server with RxJava, Vert.x and Android

During Hack Your Career event at the Silesian University of Technology, I’ve prepared a presentation titled Reactive Programming - Efficient Server Applications with a colleague from work. Arek told about theory of Reactive Programming, shown basic concepts, data types and a few examples in the code. During my part of the presentation, I’ve wrote a very simple server and client in Java (9 on the server, 7 on the client) with Vert.x (Core and Rx), RxJava 2, OkHttp 3, Android and RxAndroid. Presentation was targeted mainly to the university students with no experience with reactive programming, but it was an open event and anyone could attend it. Below, we can see a very simple code snippet showing how to create a reactive HTTP server with Vert.x. We can create a stream of requests, make Flowable out of it, apply any kind of RxJava 2 operator including backpressure handling and subscribe the stream. Moreover, we can also reactively start the server with rxListen(int port) method. This is just a basic example, where will be sending request to the only one endpoint. In the case, when we want to handle more endpoints, we can use vertx-web library and design REST API. ...

November 9, 2017 · 3 min · 556 words · Piotr Wittchen

JDD 2017 - Get ready for java.util.concurrent.Flow! - summary

Recently on the JDD 2017 conference, I gave a presentation regarding introduction to Reactive Streams standard in Java 9. I also talked about existing implementations of this standard with the strongest focus on RxJava2 and created simple Reactive Streams implementation in pure Java 9 during the presentation. Below, you can find slides from this talk. View presentation on SpeakerDeck Code snippets shown during this presentation are available at https://github.com/pwittchen/java-flow-experiments. I have done a tiny live coding session during this talk. Luckily, everything went fine, the code was compiled and executed without errors. Everything I’ve done during this presentation and additional exploratory unit tests could be found in this repository so you can check it out if you’re interested. ...

October 5, 2017 · 3 min · 441 words · Piotr Wittchen

Introducing ReactiveAirplaneMode

I’m continuing Rxfication of the Android. Recently I released brand new library called ReactiveAirplaneMode. As you may guess, it allows listening Airplane mode on Android device with RxJava observables. A usual I’ve hidden all implementation details, BroadcastReceivers and rest of the Android related stuff behind RxJava abstraction layer, so API is really simple. Just take a look on that: ReactiveAirplaneMode.create() .observe(context) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(isOn -> textView.setText(String.format("Airplane mode on: %s", isOn.toString()))); In the code above subscriber will be notified only when airplane mode changes. If you want to read airplane mode and then listen to it, you can use the following method: ...

August 15, 2017 · 1 min · 198 words · Piotr Wittchen