Contained in: Reactive Programming with Kotlin
combine
Android & Kotlin
Chapter in Reactive Programming with Kotlin
Combining Operators
Aug 6 2020 · Chapter
This chapter will show you several different ways to assemble sequences, and how to combine the data within each sequence…
Android & Kotlin
Chapter in Reactive Programming with Kotlin
Combining Operators in Practice
Aug 6 2020 · Chapter
…previous chapter, you learned about combining operators and worked through increasingly more detailed exercises on some rather mind-bending concepts. Some operators may have left you wondering about the real-world application of these reactive concepts. In this “… in practice” chapter, you’ll have the opportunity to try some…
Android & Kotlin
Chapter in Reactive Programming with Kotlin
RxBindings
Aug 6 2020 · Chapter
…enum. You can see this list in X.kt. That’s a hard nut to crack, since there’s a near infinite number of color combinations you can use in the app. Next up, manually tapping the digits can be a bit burdensome. It’d be nice if you could also…
Android & Kotlin
Chapter in Reactive Programming with Kotlin
Observables & Subjects in Practice
Aug 6 2020 · Chapter
…objects. Then, if there are any photos, you’re mapping each Photo object to a Bitmap using the BitmapFactory.decodeResource() method. Next up, you’re combining that list of bitmaps using the combineImages() method. Finally, you’re setting the collageImage image view with the combined bitmap. Run the app. When…
Android & Kotlin
Chapter in Reactive Programming with Kotlin
Transforming Operators in Practice
Aug 6 2020 · Chapter
…instead of always fetching the latest activity for a given repo like RxKotlin, you will find the top trending Kotlin repositories and display their combined activity in the app. At first sight, this might look like a lot of work, but in the end you’ll find it’s only…
Android & Kotlin
Chapter in Reactive Programming with Kotlin
Building a Complete RxJava App
Aug 6 2020 · Chapter
…user taps the done button. You have access to two crucial Observables in the EditTaskViewModel that will help you implement this feature: If you combine the finishedClicks Observable with the taskTitleTextChanges Observable, you’ll have the latest text whenever the done button is tapped. Open EditTaskViewModel.kt and start off another…
Android & Kotlin
Chapter in Reactive Programming with Kotlin
Retrofit
Aug 6 2020 · Chapter
…share() You’re using flatMap to create a new Observable every time the user clicks on the floating action button. The new Observable will combine the latest values emitted by the keyChanges and valueChanges Observables, thus emitting the current text in the left key EditText and the right value EditText…
Android & Kotlin
Chapter in Reactive Programming with Kotlin
Hello, RxJava!
Aug 6 2020 · Chapter
…speak to you. The hardware and software remains the same, but what’s changed is the state. As soon as you restart, the same combination of hardware and software will work just fine once more. The data in memory, the data stored on disk, all the artifacts of reacting…
Android & Kotlin
Chapter in Reactive Programming with Kotlin
Flowables & Backpressure
Aug 6 2020 · Chapter
…solid chunk of code, so breaking it down step by step: Create a new Observable by using the zip function, which, as you know, combines two Observables together. You’re using the RxKotlin factory function to keep everything neat. It also makes a Pair from the two emitted items…
Android & Kotlin
Chapter in Reactive Programming with Kotlin
Testing RxJava Code
Aug 6 2020 · Chapter
…then creating a new ambObservable using the ambWith method. The amb and ambWith methods are very handy — they take two or more Observables and combine them into a resulting Observable that mirrors the first Observable to fire. The other Observable is discarded. amb comes in very handy when you have…
Android & Kotlin
Chapter in Reactive Programming with Kotlin
Creating Custom Reactive Extensions
Aug 6 2020 · Chapter
Nice! This line of code really shows how powerful it is to create reactive wrappers around traditionally callback based APIs. You can now combine your permission logic and your location logic into one simple declarative stream. In this app you don’t actually want to keep listening for location updates…
Android & Kotlin
Chapter in Reactive Programming with Kotlin
RxJava & Jetpack
Aug 6 2020 · Chapter
Paging library comes with an RxJava extension that allows you to stream PagedList objects. Room and the Paging library make for a fantastic reactive combination! Where to go from here? The Room and Paging libraries are great examples of how a library can effectively integrate Rx into its API. Given…
Android & Kotlin
Chapter in Reactive Programming with Kotlin
Observables
Aug 6 2020 · Chapter
…guess how each one is specialized? Singles will emit either a success(value) or error event. success(value) is actually a combination of the next and completed events. This is useful for one-time processes that will either succeed and yield a value or fail, such as downloading data…
Android & Kotlin
Chapter in Reactive Programming with Kotlin
Filtering Operators in Practice
Aug 6 2020 · Chapter
…prevent certain elements from coming through the stream, like allowing only landscape and not portrait photos. Implementing a uniqueness filter can be achieved by combining filter with the current value of a BehaviorSubject. Debouncing with the debounce operator helps you to get around pesky bugs that occur in apps…
Android & Kotlin
Chapter in Reactive Programming with Kotlin
Subjects
Aug 6 2020 · Chapter
…complete and error events to be sent. Where to go from here? You’ve now learned about Observables and observers, and seen how to combine them into a single type called a subject. Now it’s time to put all you’ve learned into practice in an Android…
Android & Kotlin
Chapter in Reactive Programming with Kotlin
Time-Based Operators
Aug 6 2020 · Chapter
…view and the source sequence element to generate a contextual value, every time window emits a new sequence. You might want to use a combination of zip and flatMap for this. Key points When a sequence emits items, you’ll often need to make sure that a future subscriber receives…
Android & Kotlin
Chapter in Reactive Programming with Kotlin
Error Handling in Practice
Aug 6 2020 · Chapter
…least, you need to make sure that you’re only retrying the network request a certain number of times. This can be done when combined with the scan() method you just wrote. Replace the body of the scan() lambda, which currently contains this code: .scan(1) { count, _ -> count…
Android & Kotlin
Chapter in Reactive Programming with Kotlin
RxPermissions
Aug 6 2020 · Chapter
…interface to request a permission and listen to the results via an Observable. Since it’s hooked into the RxJava world, you can easily combine it with the result of location.clicks to request a permission anytime a user clicks the Location button. Isn’t that magical? Now that…