Skip to content

A simple way to create shared view models between android and iOS using KMM

Notifications You must be signed in to change notification settings

josebraz/KMMViewModelSample

Repository files navigation

KMMViewModelSample

A simple way to create shared view models between android and iOS using KMM

PlatformViewModel creates a platform-specific abstraction to use the native android ViewModel class and viewModelScope property.

StateFlowWrapper is a wrapper for kotlin flow to enable Swift code to collect values for any change.

Build Android

On Android, the shared module is seen as a traditional module and the build is trivial (open project in Android Studio and run)

Build iOS

To build an iOS app using KMM we need to build the shared module first. On the project folder run ./gradlew createSwiftpackage to build a shared module as Swift package.

Example App

This repository includes a stupid example app that counts clicks and shows the current time updating every second.

Android iOS
Android iOS

About

A simple way to create shared view models between android and iOS using KMM

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published