KMMT : Kotlin Multiplatform Mobile Template
Kotlin Multiplatform Mobile Development Simplified
KMMT is a KMM based project template designed to simplify the KMM development. It uses a simplified approach that can be
shared both in android and iOS easily.
Primary objective of this project is to help KMM Developers & promote KMM technology
Credits : KaMP Kit
IDE Requirements
IntelliJ/Android Studio - Android & Shared Module
Xcode - iOS Project
✨Features ✨
1. Simple Networking API ( Ktor )
Create API Services using BaseAPI class. All network responses are wrapped in Either data type
2. Async Task Helper ( Kotlinx.Coroutines )
Run code (Networking calls, Heavy calculations, Large dataSets from local DB, etc..) in Background thread and get the
result in UI thread.
Return value from background
3. Multiplatform Bundle : Object Passing B/W Activities or ViewControllers
View Model can pass objects & values from Activity to Activity (Android) or ViewController to ViewController (iOS)
Send Values From 1st View Model
Retrieve Values From 2nd View Model
4. Platform Blocks
Execute anything specific to a particular platform using Platform Blocks
5. Object Serialization Helper ( Kotlinx.Serialization )
Use toJsonString and toObject functions for instant serialization.
Objects to String Serialization
String to Object Serialization
6. Key Value Store ( Multiplatform Settings )
Use storeValue and getStoreValue functions for storing and retrieving Key-Value respectively
Storing Key-Value pair
Retrieve Value using Key
7. LiveData & LiveDataObservable ( LiveData )
LiveData follows the observer pattern. LiveData notifies Observer objects when underlying data changes. You can
consolidate your code to update the UI in these Observer objects. That way, you don't need to update the UI every time
the app data changes because the observer does it for you.
8. Observe with DBHelper ( Local Database : SQLite - SQLDelight )
Use 'asFlow()' extension from DBHelper class to observe a query data
9. Useful Functional Programming
use Either data type to represent a value of one of two possible types (a disjoint union). Instances of Either are
either an instance of Failure or Success
convert or map SuccessType using flatMap or map
use either blocks( either or eitherAsync [for suspended method support] ) to define failure & success
functionalities
10. Data Cache Helper
Use BaseDataCache<RequestParamType, DataType> to implement data caching (remote to local). call cacheData function
to get and save data
How to use
Shared Module (Business Logics & UI Binding Methods) :
Step 1 : Define View
- Create a View interface by extending from BaseView.
- Define UI binding functions in View interface.
Step 2 : Define ViewModel
- Create a ViewModel class by extending from BaseViewModel with View as Type.
- Define your business logic in ViewModel class.
Android Module UI Binding :
Step 3 : Define Android View
- Create new activity by extending from KMMActivity with ViewModel as Type.
- Implement created View interface in activity.
- Implement all necessary methods from View & KMMActivity.
Implement LoginView & Bind UI Controls
iOS Module UI Binding (Xcode) :
Step 4 : Define iOS View
- Create new viewcontroller by extending from KMMUIViewController.
- Implement created View interface in viewcontroller.
- Implement all necessary methods from View & KMMUIViewController.
Implement LoginView & Bind UI Controls