TagKotlin

MVVM vs MVI – Architecture for Mobile Development

M

The Model-View-ViewModel (MVVM) and Model-View-Intent (MVI) are architectural patterns used in software development, particularly for structuring the code of user interface (UI) applications. Both patterns aim to separate concerns and manage the flow of data between the UI and the underlying data models, but they do so in different ways. Let’s explore both patterns with an example in...

Exploring Kotlin’s suspendCoroutine: A Guide with Examples

E

Introduction: Kotlin, with its modern syntax and powerful features, has taken the programming world by storm. One of its unique offerings is the suspendCoroutine function, a game-changer when it comes to handling asynchronous operations. In this article, we’ll dive into the world of suspendCoroutine, demystifying its usage and providing you with real-world examples to showcase its...

Convert Callback Into Kotlin Coroutines Suspend or Deferred

C

Since coroutine is a hot topic in mobile development, converting vanilla JVM callback into Kotlin Coroutines is desirable. The wrapping happens using something called SuspendCoroutine. What is a SuspendCoroutine suspendCoroutine is a builder function that mainly used to convert callbacks into suspend functions. Let’s say for example you have some legacy (or not) Api...

Kotlin Scoping Functions apply vs. with, let, also, and run

K

Functional-style programming is highly advocated and supported by Kotlin’s syntax as well as a range of functions in Kotlin’s standard library. In this post we will examine five Kotlin scoping functions (aka higher-order functions): apply, with, let, also, and run. When learning these five functions, you will need to memorize 2 things: how to use them, and when to use them...

Number of Islands solution

N

In this post, we have a look at using a queue and breath-first search algorithm to solve a Leetcode challenge. The problem is stated as follows. Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges...

PetaMinds focuses on developing the coolest topics in data science, A.I, and programming, and make them so digestible for everyone to learn and create amazing applications in a short time.

Categories