Skip to content

Plus Mobile Apps Blog

Letting a Decompose BLoC Render Itself

I use Decompose to manage navigation in my Kotlin Multiplatform projects. It does a great job of modeling navigation as a tree of business logic components (BLoCs) that are completely platform- and UI-agnostic. But that agnosticism comes with a small tax: something, somewhere, still has to decide which composable to draw for each BLoC. This post is about how I got rid of that boilerplate by giving each BLoC the ability to render itself since Chef Mate uses Compose Multiplatform to render its UI.

Kotlin Multiplatform UI Text Models With TextData

One practice I picked up at Square was separating business logic from the UI through a text model — a sealed class that abstracts whether displayed text comes from a fixed string, a string resource, or a formatted string. This creates a clean separation of concerns between business logic and presentation logic.

Chef Mate

Image title

Chef Mate is an open source Kotlin Multiplatform recipe keeper, meal planner, and grocery list app that targets Android, iOS, and JVM (Windows, Mac, and Linux).

Extending Kotlin Inject Anvil for Assisted Factories

Image title

I recently started using Kotlin inject anvil in my kotlin multiplatform (KMP) projects for dependency injection. However when using assisted injection I noticed myself writing boilerplate code to bind assisted factory method interfaces. In the process of trying to not write all this boiler plate code, I ended up writing a library that extends kotlin inject anvil to generate the code necessary to bind the assisted factory interface. Learn how to use this extension to bind assisted factory method interfaces.

Ktor Database Beginners Guide

I have been using Ktor, PostgreSQL, and Jetbrains Exposed for a backend in a hobby project. I was adding a new feature that required making changes to the database, so after a quick Google search found a Stackoverflow answer recommending using Flyway to manage the database migrations. I was looking for a more complete solution to this answer, so ended up creating a sample project to share my learnings in migrating a Postgres database with Flyway in a Ktor project.

Surviving Android Process Death With SavedStateFlow

I was perusing Reddit the other day when someone asked how they could use SavedStateHandle with a StateFlow similar to the SavedStateHandle.getLiveData() version. The most upvoted comment originally was saying that this functionality is not officially supported, but one could convert the LiveData to a Flow using the LiveData.asFlow() extension function. That seemed pretty simple for anyone to do, however testing that would then require using LiveData in your tests which might be annoying if you were using StateFlow to manage state. So after looking over the API, it seemed pretty simple to write a wrapper that could expose this functionality directly as a StateFlow and that is how the SavedStateFlow library was made!

How to test a custom Android view with Robolectric

Working at an enterprise that needs a custom component library with each component being its own snow flake and having more complicated logic than the next. I found myself needing a way to test the logic in these views to ensure I could iterate quickly and not break anything in the process.

How to build a Slackbot with Kotlin

One day at my day job, I noticed that there were a couple of services we used that anytime an event happened there was a very manual process for the developer to copy paste data into a Slack channel for others to be aware of the issue. I thought there had to be a better way to automate this whole process and prevent a developer from having to do this tedious task. That was when I came up with the idea of creating a Slackbot application to do this. So in this article I will describe the process I went through to create a Slackbot using Ktor and webhooks that can post messages to your Slack channel of choice and how to deploy to Heroku. For this example, we will be using Github webhooks to supply data to our Slackbot but the same principal applies to your service of choice that offers webhooks.