<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

 <title>Wyko Rijnsburger</title>
 <link href="/atom.xml" rel="self"/>
 <link href="https://www.wykorijnsburger.nl/"/>
 <updated>2026-02-20T06:36:01+00:00</updated>
 <id>https://www.wykorijnsburger.nl</id>
 <author>
   <name>Wyko Rijnsburger</name>
   <email>utwyko@gmail.com</email>
 </author>

 
 <entry>
   <title>Favorite Media of 2025</title>
   <link href="https://www.wykorijnsburger.nl/personal/2026/01/02/favorite-media-2025/"/>
   <updated>2026-01-02T00:00:00+00:00</updated>
   <id>https://www.wykorijnsburger.nl/personal/2026/01/02/favorite-media-2025</id>
   <content type="html">&lt;p&gt;Some of my 2025 favorites. Music has to be released in 2025, the rest are just my favorite things regardless of publication year.&lt;/p&gt;

&lt;h2 id=&quot;games&quot;&gt;Games&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;Ghost of Yotei&lt;/li&gt;
  &lt;li&gt;The Legend of Zelda: Echoes of Wisdom&lt;/li&gt;
  &lt;li&gt;God of War Ragnarök&lt;/li&gt;
  &lt;li&gt;Ball x Pit&lt;/li&gt;
  &lt;li&gt;Donkey Kong Bonanza&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;books&quot;&gt;Books&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;The Bee Sting - Paul Murray&lt;/li&gt;
  &lt;li&gt;Tupac Shakur: The Authorized Biography - Staci Robinson&lt;/li&gt;
  &lt;li&gt;De Eerste - Sophie Visser&lt;/li&gt;
  &lt;li&gt;How to Write One Song - Jeff Tweedy&lt;/li&gt;
  &lt;li&gt;The City and Its Uncertain Walls - Haruki Murakami&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;movies&quot;&gt;Movies&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;The Holdovers&lt;/li&gt;
  &lt;li&gt;One Battle After Another&lt;/li&gt;
  &lt;li&gt;Anora&lt;/li&gt;
  &lt;li&gt;Red Rocket&lt;/li&gt;
  &lt;li&gt;Bugonia&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;music&quot;&gt;Music&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;Lonely People with Power - Deafheaven&lt;/li&gt;
  &lt;li&gt;Dali Ain’t Dead - Zelooperz&lt;/li&gt;
  &lt;li&gt;Showbiz! - MIKE&lt;/li&gt;
  &lt;li&gt;Mercy - Armand Hammer&lt;/li&gt;
  &lt;li&gt;Let God Sort Em Out - Clipse&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;tv&quot;&gt;TV&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;The Rehearsal S02&lt;/li&gt;
  &lt;li&gt;Pluribus S02&lt;/li&gt;
  &lt;li&gt;Andor S02&lt;/li&gt;
  &lt;li&gt;The Chair Company S01&lt;/li&gt;
  &lt;li&gt;Severance S02&lt;/li&gt;
&lt;/ol&gt;
</content>
 </entry>
 
 <entry>
   <title>Comparing Build Performance between JDKs in Android Studio</title>
   <link href="https://www.wykorijnsburger.nl/dev/2020/08/29/jdk-build-performance-as-studio/"/>
   <updated>2020-08-29T00:00:00+00:00</updated>
   <id>https://www.wykorijnsburger.nl/dev/2020/08/29/jdk-build-performance-as-studio</id>
   <content type="html">&lt;p&gt;By default Android Studio builds projects using its embedded JDK8. IntelliJ IDEA product manager Dmitry Jemerov says &lt;a href=&quot;https://stackoverflow.com/a/52914187/2999211&quot;&gt;you should use the embedded JDK in Android Studio&lt;/a&gt;. My typical workflow while developing is:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Write code in Android Studio.&lt;/li&gt;
  &lt;li&gt;Verify the result by either running the app or running a specific set of tests in Android Studio.&lt;/li&gt;
  &lt;li&gt;If everything is OK, run all tests and the linter through the terminal.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the terminal I use the JDK set as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;JAVA_HOME&lt;/code&gt; by &lt;a href=&quot;https://github.com/jenv/jenv&quot;&gt;jenv&lt;/a&gt;. I want my JDK setup decoupled from Android Studio, using the embedded JDK as the default Java is not an option.&lt;/p&gt;

&lt;p&gt;Using two different JDKs creates two separate &lt;a href=&quot;https://docs.gradle.org/current/userguide/gradle_daemon.html&quot;&gt;Gradle Daemons&lt;/a&gt;. The Daemon contains the build cache, so one JDK cannot use the build cache of the other JDK.
In this case, running all tests and the linter cannot reuse the build cache from the embedded JDK so this step takes a lot longer than necessary.&lt;/p&gt;

&lt;p&gt;Using the same JDK in both Android Studio and the terminal solves this, although this goes against Dmitry’s recommendation. The project I work on is compatible with JDK14, so for a few weeks I used JDK14 in both places. I had the feeling that builds run in Android Studio were taking longer than with the embedded JDK, so I ran a quick, non conclusive experiment comparing the build performance of Android Studio (see test setup below).&lt;/p&gt;

&lt;p&gt;My simple test does not show any significant difference between JDKs. So until there is a good reason to switch back to the embedded JDK, I will continue using JDK14 in Android Studio.&lt;/p&gt;

&lt;ul class=&quot;BarList&quot;&gt;
    &lt;li class=&quot;BarLi&quot;&gt;&lt;span class=&quot;ChartLabel&quot;&gt;Embedded JDK8&lt;/span&gt;&lt;span class=&quot;BarSep&quot;&gt; : &lt;/span&gt;&lt;span class=&quot;BarValue&quot; style=&quot;--bar-length:88%&quot;&gt;181.1&lt;/span&gt;&lt;/li&gt;
    &lt;li class=&quot;BarLi&quot;&gt;&lt;span class=&quot;ChartLabel&quot;&gt;AdoptOpenJDK 1.8.0_265&lt;/span&gt;&lt;span class=&quot;BarSep&quot;&gt; : &lt;/span&gt;&lt;span class=&quot;BarValue&quot; style=&quot;--bar-length:82%&quot;&gt;170.6&lt;/span&gt;&lt;/li&gt;
    &lt;li class=&quot;BarLi&quot;&gt;&lt;span class=&quot;ChartLabel&quot;&gt;AdoptOpenJDK 14.0.2&lt;/span&gt;&lt;span class=&quot;BarSep&quot;&gt; : &lt;/span&gt;&lt;span class=&quot;BarValue&quot; style=&quot;--bar-length:90%&quot;&gt;185.2&lt;/span&gt;&lt;/li&gt;
    &lt;li class=&quot;BarLi&quot;&gt; &lt;span class=&quot;XTicks&quot;&gt;
            &lt;span class=&quot;TickLabel&quot; style=&quot;--tick-label:&apos;0.0&apos;&quot;&gt;&lt;/span&gt;
            &lt;span class=&quot;TickLabel&quot; style=&quot;--tick-label:&apos;51.4&apos;&quot;&gt;&lt;/span&gt;
            &lt;span class=&quot;TickLabel&quot; style=&quot;--tick-label:&apos;102.9&apos;&quot;&gt;&lt;/span&gt;
            &lt;span class=&quot;TickLabel&quot; style=&quot;--tick-label:&apos;154.3&apos;&quot;&gt;&lt;/span&gt;
            &lt;span class=&quot;TickLabel&quot; style=&quot;--tick-label:&apos;205.8&apos;&quot;&gt;&lt;/span&gt;
        &lt;/span&gt;
    &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;(Values are in seconds.)&lt;/p&gt;

&lt;h3 id=&quot;test-setup&quot;&gt;Test Setup&lt;/h3&gt;
&lt;p&gt;I rebuilt the project from Android Studio using each JDK six times. I excluded the results of the first rebuild after switching JDKs as rebuilding reuses some of the previous builds config.&lt;/p&gt;

&lt;h4 id=&quot;project&quot;&gt;Project&lt;/h4&gt;
&lt;ul&gt;
  &lt;li&gt;37 gradle modules&lt;/li&gt;
  &lt;li&gt;KAPT with Dagger&lt;/li&gt;
  &lt;li&gt;90% Kotlin, 10% Java&lt;/li&gt;
  &lt;li&gt;Jetifier enabled&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;machine&quot;&gt;Machine&lt;/h4&gt;
&lt;ul&gt;
  &lt;li&gt;MacBook Pro (15-inch 2018)&lt;/li&gt;
  &lt;li&gt;Processor: 2,5 GHz 6-core Intel  Core i7&lt;/li&gt;
  &lt;li&gt;Memory: 16GB 240MHz DDR4&lt;/li&gt;
  &lt;li&gt;Graphics: Intel UHD Graphics 650 1536 MB&lt;/li&gt;
  &lt;li&gt;OS: macOS Catalina 10.15.6&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;android-studio&quot;&gt;Android Studio&lt;/h4&gt;
&lt;p&gt;Version 4.0.1.
Custom VM options:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;-Xms1G
-Xmx2048m
-XX:MetaspaceSize=512m
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

</content>
 </entry>
 
 <entry>
   <title>Introducing Kotlin Multiplatform incrementally</title>
   <link href="https://www.wykorijnsburger.nl/dev/2020/08/14/multiplatform/"/>
   <updated>2020-08-14T00:00:00+00:00</updated>
   <id>https://www.wykorijnsburger.nl/dev/2020/08/14/multiplatform</id>
   <content type="html">&lt;p&gt;You can use Kotlin for cross-platform development using &lt;a href=&quot;https://www.jetbrains.com/lp/mobilecrossplatform/&quot;&gt;Kotlin Multiplatform&lt;/a&gt;. Its approach differs from other cross-platform solutions such as Flutter and React Native: you can add it to existing codebases and it does not replace all platform-native code.&lt;/p&gt;

&lt;p&gt;At Blendle, we wanted to experiment with Kotlin Multiplatform on the Android, Web and iOS clients. Using a tool to build an actual production feature is usually the quickest way to evaluate a tool, so we tried to figure out the easiest and fastest way to do this. The setup also needed to be easily removeable. This was especially important for the web/iOS developers. Merging Multiplatform code back into the Android app is trivial as the majority of the Android codebase was already written in Kotlin, but this is not the case for the other platforms.&lt;/p&gt;

&lt;p&gt;We evaluated several approaches. I recommend checking out &lt;a href=&quot;https://www.youtube.com/watch?v=je8aqW48JiA&quot;&gt;this talk by Ben Asher and Alec Strong&lt;/a&gt; for an in depth evaluation of these approaches:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Merge Android/Web/iOS codebases into a single Git repository (a mono-repo), add multiplatform code there.&lt;/li&gt;
  &lt;li&gt;Duplicate the Multiplatform code in each client codebase.&lt;/li&gt;
  &lt;li&gt;Create a separate repo for Multiplatform code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We created a separate repo with its own CI pipeline. This isolated all Multiplatform code, apart from the integration into the clients, into a removable component.&lt;/p&gt;

&lt;p&gt;The first feature we build in Multiplatform was email verification: when a user signs-up with a suspicious email address (e.g. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;user@gnail.com&lt;/code&gt;) we suggest a corrected email address before the user confirms their registration. A simplified version of this already worked: we fetched a verification regex from the backend, but we were not satisfied with that implementation. Email verification was a perfect use-case for Multiplatform because:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;The logic should be identical for each client.&lt;/li&gt;
  &lt;li&gt;The email address should be verified after each key stroke. Doing the verification server-side requires a lot of traffic and adds latency.&lt;/li&gt;
  &lt;li&gt;It is easily testable in isolation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After writing the Multiplatform code, we integrated the library into the Android, Web and iOS clients.&lt;/p&gt;

&lt;p&gt;On Android, we assembled a library JAR by running the gradle &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;assemble&lt;/code&gt; task. The Android repository included the output as a local library. This is suboptimal as releasing new versions requires quite some manual work and it increases the size of the Android git repo. However, we could start integrating the Multiplatform code within a few minutes.&lt;/p&gt;

&lt;p&gt;On iOS we started out with a similar approach by producing a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.framework&lt;/code&gt; file and including that in the iOS repository. This did not work as iOS requires different frameworks for different processor architectures. So we added a Gradle task producing a Fat Framework supporting both architecture (&lt;a href=&quot;https://medium.com/@saschpe/kotlin-multiplatform-fat-framework-for-ios-cdd05ec479cb&quot;&gt;see this post for details&lt;/a&gt;). We did not want to use the Fat Framework for release builds though as it increases the size of the binary, so we created a BuildPhase in the iOS build that chooses the correct framework based on the build configuration (FAT for debug or the proper processor architecture framework for release builds).&lt;/p&gt;

&lt;p&gt;On Web, we could not get the setup to work. The functions in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;commonMain&lt;/code&gt; module were not properly exported to the Javascript outputs and the output file size was too large to include for such a simple feature. Since there are so many &lt;a href=&quot;https://blog.jetbrains.com/kotlin/2020/03/kotlin-1-4-m1-released/&quot;&gt;changes to targeting Javascript with Multiplatform&lt;/a&gt; in the upcoming Kotlin 1.4 we decided to postpone the integration with Web until after the Kotlin 1.4 release.&lt;/p&gt;

&lt;p&gt;Apart from Web, we were quite happy with the resulting setup. Using the Multiplatform Email Verification API from iOS and Android was easy and we were even able to use a &lt;a href=&quot;https://kotlinlang.org/docs/sealed-classes.html&quot;&gt;Sealed Class&lt;/a&gt; as a result type in the API. Since the first iteration we’ve build several more features in the Multiplatform library, with a majority being build in Kotlin by iOS developers! We want to make improvements to the setup, such as:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Pushing the JVM binaries to an artifactory. We do not use a custom artifactory at Blendle but GitHub actions (which we already use) offers &lt;a href=&quot;https://docs.github.com/en/packages/learn-github-packages/publishing-a-package&quot;&gt;an easy way to publish packages&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Including the Multiplatform repository into the Android build process for debug builds so that we can test changes to the Multiplatform code without having to produce a JAR.&lt;/li&gt;
&lt;/ul&gt;

</content>
 </entry>
 
 <entry>
   <title>KMinRandom 1.0.0</title>
   <link href="https://www.wykorijnsburger.nl/dev/2019/08/22/kminrandom/"/>
   <updated>2019-08-22T00:00:00+00:00</updated>
   <id>https://www.wykorijnsburger.nl/dev/2019/08/22/kminrandom</id>
   <content type="html">&lt;p&gt;Today, I published the 1.0.0 version of KMinRandom, a library for generating random test data in Kotlin. I’ve been using the library for the past two years at both Bol.com and Blendle without any major issues, so it seems appropriate to publish a “real” version. You can check out the documentation and source code at &lt;a href=&quot;https://github.com/utwyko/KMinRandom&quot;&gt;GitHub&lt;/a&gt;. Any comments, feature requests or ideas are very much welcome!&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Lessons Learned from implementing a Fragment to Fragment Shared Element transition</title>
   <link href="https://www.wykorijnsburger.nl/dev/2019/04/30/shared-element-transition/"/>
   <updated>2019-04-30T00:00:00+00:00</updated>
   <id>https://www.wykorijnsburger.nl/dev/2019/04/30/shared-element-transition</id>
   <content type="html">&lt;table&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;img src=&quot;/assets/fixed_transition_discover.gif&quot; alt=&quot;Discover transition gif&quot; /&gt;&lt;/td&gt;
      &lt;td&gt;&lt;img src=&quot;/assets/fixed_transition_recent_issues.gif&quot; alt=&quot;Recent issues transition gif&quot; /&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h3 id=&quot;1-fragments-should-be-in-the-same-container&quot;&gt;1. Fragments should be in the same container&lt;/h3&gt;
&lt;p&gt;You cannot do shared element transitions with fragments in another container.&lt;/p&gt;

&lt;h3 id=&quot;2-use-replace-instead-of-add&quot;&gt;2. Use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.replace()&lt;/code&gt; instead of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.add()&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;Shared element transitions do not work when adding fragments, even to the same container.&lt;/p&gt;

&lt;h3 id=&quot;3-enable-reordering-allowed-when-postponing-transitions&quot;&gt;3. Enable reordering allowed when postponing transitions&lt;/h3&gt;
&lt;p&gt;When the content of the transition needs to be loaded before the transition can start, we need to use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;postponeEnterTransition()&lt;/code&gt;. Postponing the transition will only work when you add &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;setReorderingAllowed(true)&lt;/code&gt; to your fragment transition (see &lt;a href=&quot;https://developer.android.com/reference/android/support/v4/app/FragmentTransaction.html#setreorderingallowed&quot;&gt;Android docs&lt;/a&gt; and the Reordering part of &lt;a href=&quot;https://chris.banes.dev/posts/fragmented-transitions/&quot;&gt;this blog post by Chris Banes&lt;/a&gt; for more context.)&lt;/p&gt;

&lt;h3 id=&quot;4-properly-resume-the-state-of-the-fragment-you-return-to-with-the-return-transition&quot;&gt;4. Properly resume the state of the fragment you return to with the return transition&lt;/h3&gt;
&lt;p&gt;In this case, the view that needs to be resumed contains a nested &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RecyclerView&lt;/code&gt; within the main &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RecyclerView&lt;/code&gt;. The shared element needs to be in view in both fragments when the transition takes place. Therefore the nested &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RecyclerView&lt;/code&gt; needs to be restored to it’s previous state before the transition is started. This is done automatically when we use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.add()&lt;/code&gt; to add the view because that means the view will remain in memory. However, using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.replace()&lt;/code&gt; means that the fragment to which we need to return has been destroyed and needs to be recreated through the fragment lifecycle.&lt;/p&gt;

&lt;p&gt;Using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;onSavedInstanceState()&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;onRestoreInstanceState()&lt;/code&gt; methods of the nested &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RecyclerView&lt;/code&gt;, the state needs to be manually restored. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;startPostponedEnterTransition&lt;/code&gt; should be called when the shared element on the restored fragment is fully rendered.&lt;/p&gt;

&lt;h3 id=&quot;5-to-transition-a-cardview-with-an-image-add-both-the-card-and-the-image-as-shared-elements&quot;&gt;5. To transition a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CardView&lt;/code&gt; with an image, add both the card and the image as shared elements&lt;/h3&gt;
&lt;p&gt;Doing the transition on just the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CardView&lt;/code&gt; won’t dynamically scale the image during the transition. If you do the transition on just the image, the card already be at its final position at the start of the transition.&lt;/p&gt;

&lt;h3 id=&quot;6-postponeentertransition-and-startpostponedentertransition-also-work-for-return-transitions&quot;&gt;6. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;postponeEnterTransition()&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;startPostponedEnterTransition()&lt;/code&gt; also work for return transitions&lt;/h3&gt;
&lt;p&gt;The naming of these functions is really confusing but they work exactly the same for return transitions.&lt;/p&gt;

&lt;h3 id=&quot;7-setcustomanimations-fade-inout-causes-shared-element-flicker-individual-fade-inout-fixes-this&quot;&gt;7. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;setCustomAnimations&lt;/code&gt; fade-in/out causes shared element flicker. Individual fade-in/out fixes this&lt;/h3&gt;
&lt;p&gt;Using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out)&lt;/code&gt; to add the fragment fade-in/out animation causes a subtle flicker on the shared element whenever the shared element transition is finished. This is fixed by setting a separate fade-in/out transition on the individual fragments:&lt;/p&gt;

&lt;div class=&quot;language-kotlin highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;currentFragment&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;exitTransition&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;TransitionInflater&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;inflateTransition&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;android&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;transition&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fade&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;newFragment&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;enterTransition&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;TransitionInflater&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;inflateTransition&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;android&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;transition&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fade&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;However, these transitions persist past this fragment transaction. If the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exitTransition&lt;/code&gt; of the fragment is not reset, a fade will be shown when returning to this fragment from other fragments, even if no specific animation is specified. We can easily clear this by resetting the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exitTransition&lt;/code&gt; when the shared element transition is finished.&lt;/p&gt;

&lt;div class=&quot;language-kotlin highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;fragment&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sharedElementEnterTransition&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;TransitionInflater&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;inflateTransition&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;android&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;transition&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;move&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;addListener&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;object&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;TransitionListenerAdapter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onTransitionEnd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;transition&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Transition&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// The current fragment transition should only be applied for this transition and be removed afterwards&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;currentFragment&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;exitTransition&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;null&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</content>
 </entry>
 
 <entry>
   <title>The Reactive Rollercoaster</title>
   <link href="https://www.wykorijnsburger.nl/dev/2018/07/14/reactive-talk-spaces-summit/"/>
   <updated>2018-07-14T00:00:00+00:00</updated>
   <id>https://www.wykorijnsburger.nl/dev/2018/07/14/reactive-talk-spaces-summit</id>
   <content type="html">&lt;p&gt;I recently gave a talk at the Bol.com conference ‘Spaces Summit’ on how we used Reactive technologies to build a new backend for the Bol.com mobile apps. In the talk, I discuss the pros and cons of a Reactive approach, tell some horror stories about the issues we ran into during the development and I give tips and tricks for building resilient and performant Reactive JVM backend apps. The slides can be found in the description of the YouTube video.&lt;/p&gt;

&lt;iframe width=&quot;700&quot; height=&quot;450&quot; src=&quot;https://www.youtube.com/embed/a6W0Sc00lBc&quot; frameborder=&quot;0&quot; allow=&quot;autoplay; encrypted-media&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;
</content>
 </entry>
 
 <entry>
   <title>Combining Streams using Reactor 3 + Kotlin</title>
   <link href="https://www.wykorijnsburger.nl/dev/2017/08/22/zip-operations-kotlin-reactor/"/>
   <updated>2017-08-22T00:00:00+00:00</updated>
   <id>https://www.wykorijnsburger.nl/dev/2017/08/22/zip-operations-kotlin-reactor</id>
   <content type="html">&lt;p&gt;I spent a day migrating a service that does a lot of aggregation from &lt;a href=&quot;https://github.com/ReactiveX/RxJava&quot;&gt;RxJava 1&lt;/a&gt; to &lt;a href=&quot;https://projectreactor.io/&quot;&gt;Reactor 3&lt;/a&gt;. The migration went pretty smooth, with the Reactor API being more elegant compared to RxJava in most cases.&lt;/p&gt;

&lt;p&gt;However, I struggled migrating the large &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zip()&lt;/code&gt; operations, where we merge async data from various sources into one big Observable. RxJava has &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zip&lt;/code&gt; that works like this:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;T1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;T2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;T3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;T4&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;T5&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Single&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;zip&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Single&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;?&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;T1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;o1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;
                                   &lt;span class=&quot;nc&quot;&gt;Single&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;?&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;T2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;o2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;
                                   &lt;span class=&quot;nc&quot;&gt;Single&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;?&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;T3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;o3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;
                                   &lt;span class=&quot;nc&quot;&gt;Single&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;?&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;T4&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;o4&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;
                                   &lt;span class=&quot;nc&quot;&gt;Single&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;?&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;T5&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;o5&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;
                                   &lt;span class=&quot;nc&quot;&gt;Func5&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;?&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;super&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;T1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,?&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;super&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;T2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,?&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;super&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;T3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,?&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;super&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;T4&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,?&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;super&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;T5&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,?&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;zipFunction&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;While I think from a maintenance perspective, this is far from ideal, as a user, the resulting code becomes quite readable:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;nc&quot;&gt;Single&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;zip&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;singleA&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;singleB&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;singleC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;singleD&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;singleE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; 
           &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Aggregate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;In Reactor, the API unfortunately isn’t as user-friendly. In the combinator function, you lose all type information which results in a long, ugly Function where we’re forced to do manual casting.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;nc&quot;&gt;Mono&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;zip&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;no&quot;&gt;A&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;];&lt;/span&gt;
    &lt;span class=&quot;no&quot;&gt;B&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;];&lt;/span&gt;
    &lt;span class=&quot;no&quot;&gt;C&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;C&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;];&lt;/span&gt;
    &lt;span class=&quot;no&quot;&gt;D&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;D&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;];&lt;/span&gt;
    &lt;span class=&quot;no&quot;&gt;E&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;E&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;];&lt;/span&gt;
    
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Aggregate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;monoA&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;monoB&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;monoC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;monoD&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;monoE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;There is also the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;when&lt;/code&gt; approach, which returns a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Tuple&lt;/code&gt; that you can then transform. This approach is slightly more maintainable as it does not require manual casting, but is not that readable:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;nc&quot;&gt;Mono&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;when&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;monoA&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;monoB&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;monoC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;monoD&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;monoE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tuple&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Aggregate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tuple&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;t1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tuple&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;t2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tuple&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;t3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tuple&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;t4&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tuple&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;t5&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()))&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;In &lt;a href=&quot;https://kotlinlang.org/&quot;&gt;Kotlin&lt;/a&gt;, we can improve this by using the Tuple Extension Functions for Kotlin provided by Reactor. These &lt;a href=&quot;https://kotlinlang.org/docs/extensions.html&quot;&gt;Kotlin extension functions&lt;/a&gt; provide &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;component()&lt;/code&gt; methods to the Reactor Tuples which allow us to use &lt;a href=&quot;https://kotlinlang.org/docs/destructuring-declarations.html&quot;&gt;Kotlin’s Destructuring Declarations syntax&lt;/a&gt;. We need to manually import these extension functions, in my experience IDEA does not do it for you.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-kotlin&quot; data-lang=&quot;kotlin&quot;&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;reactor.util.function.component1&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;reactor.util.function.component2&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;reactor.util.function.component3&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;reactor.util.function.component4&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;reactor.util.function.component5&lt;/span&gt;

&lt;span class=&quot;nc&quot;&gt;Mono&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;when&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;monoA&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;monoB&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;monoC&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;monoD&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;monoE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;map&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Aggregate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

</content>
 </entry>
 
 <entry>
   <title>Rate-limiting API-calls with Reactor 3</title>
   <link href="https://www.wykorijnsburger.nl/dev/2017/02/14/rate-limiting-using-reactor/"/>
   <updated>2017-02-14T20:40:35+00:00</updated>
   <id>https://www.wykorijnsburger.nl/dev/2017/02/14/rate-limiting-using-reactor</id>
   <content type="html">&lt;p&gt;I’ve been working with &lt;a href=&quot;https://projectreactor.io/&quot;&gt;Reactor 3&lt;/a&gt; recently. Reactor is a Reactive library similar to RxJava, but developed for Java 8 by the guys at Spring.&lt;/p&gt;

&lt;p&gt;I ran into a situation where I had to call an external API for all items in a stream. That external API only allowed four requests a second, so I had to rate-limit the outgoing calls. Luckily, using Reactor, this is easily implemented.&lt;/p&gt;

&lt;p&gt;We can use the &lt;a href=&quot;https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Flux.html#delayElements-java.time.Duration-&quot;&gt;delayElements&lt;/a&gt; method on the stream to limit the amount of emitted items per second.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;nc&quot;&gt;Flux&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;just&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;ID1&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;ID2&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;delayElements&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Duration&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;ofMillis&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;250&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;apiClient&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;doSomething&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;));&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h4 id=&quot;update-12th-april-2017&quot;&gt;Update 12th April 2017&lt;/h4&gt;
&lt;p&gt;This post has been updated to use the new &lt;a href=&quot;https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Flux.html#delayElements-java.time.Duration-&quot;&gt;delayElements&lt;/a&gt; method instead of the now deprecated &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;delayMillis&lt;/code&gt;.&lt;/p&gt;

</content>
 </entry>
 

</feed>
