All Projects → florent37 → Multiplatform-LiveData

florent37 / Multiplatform-LiveData

Licence: Apache-2.0 license
Multiplatorm implementation of LiveDatas / MVVM in kotlin android & native ios

Programming Languages

kotlin
9241 projects
shell
77523 projects

Projects that are alternatives of or similar to Multiplatform-LiveData

Android Arch Components Date Countdown
Stars: ✭ 207 (+117.89%)
Mutual labels:  components, architecture, livedata
Newandroidarchitecture Component Github
Sample project based on the new Android Component Architecture
Stars: ✭ 229 (+141.05%)
Mutual labels:  architecture, observable, livedata
Android Mvvm Architecture
A basic sample android application to understand MVVM in a very simple way.
Stars: ✭ 129 (+35.79%)
Mutual labels:  architecture, livedata
Mvikotlin
Extendable MVI framework for Kotlin Multiplatform with powerful debugging tools (logging and time travel)
Stars: ✭ 483 (+408.42%)
Mutual labels:  native, multiplatform
Votlin App
Kotlin multiplatform project
Stars: ✭ 193 (+103.16%)
Mutual labels:  native, multiplatform
Livedata Call Adapter
A simple LiveData call adapter for retrofit
Stars: ✭ 119 (+25.26%)
Mutual labels:  architecture, livedata
Androidarchitecture
Android Architecture using Google guides
Stars: ✭ 127 (+33.68%)
Mutual labels:  architecture, livedata
Multiplatform Preferences
Kotlin Multi Platform Preferences, for android an ios : SharedPreferences & NSUserDefault
Stars: ✭ 76 (-20%)
Mutual labels:  native, multiplatform
Klock
Multiplatform Date and time library for Kotlin
Stars: ✭ 569 (+498.95%)
Mutual labels:  native, multiplatform
Decompose
Kotlin Multiplatform lifecycle-aware business logic components (aka BLoCs) with routing functionality and pluggable UI (Jetpack Compose, SwiftUI, JS React, etc.)
Stars: ✭ 339 (+256.84%)
Mutual labels:  components, multiplatform
ObservableCollections
Observable Collectons for Android Kotlin apps. Observes adds, deletes etc.
Stars: ✭ 19 (-80%)
Mutual labels:  observable, livedata
Androidarchitecture
Recommended architecture by Android
Stars: ✭ 883 (+829.47%)
Mutual labels:  architecture, livedata
Wanandroid
🏄 基于Architecture Components dependencies (Lifecycles,LiveData,ViewModel,Room)构建的WanAndroid开源项目。 你值得拥有的MVVM快速开发框架:https://github.com/jenly1314/MVVMFrame
Stars: ✭ 410 (+331.58%)
Mutual labels:  architecture, livedata
Android Architecture Components Kotlin
Sample used to practice Kotlin and Android Architecture Components.
Stars: ✭ 326 (+243.16%)
Mutual labels:  architecture, livedata
Decompose
Kotlin Multiplatform lifecycle-aware business logic components (aka BLoCs) with routing functionality and pluggable UI (Jetpack Compose, SwiftUI, JS React, etc.), inspired by Badoos RIBs fork of the Uber RIBs framework
Stars: ✭ 799 (+741.05%)
Mutual labels:  components, multiplatform
PlayAndroid
✌️✊👋玩安卓Mvvm组件化客户端,整合Jetpack组件DataBinding、ViewModel以及LiveData;屏幕适配✔️状态栏沉浸式✔️黑夜模式✔️,无数据、加载失败状态页;骨架屏、Koin依赖注入等
Stars: ✭ 193 (+103.16%)
Mutual labels:  components, livedata
Multiplatform-Log
Kotlin Multi Platform Logger, for android an ios : Logcat & print
Stars: ✭ 49 (-48.42%)
Mutual labels:  native, multiplatform
kotlin-simple-architecture
Kotlin Simple Architecture
Stars: ✭ 35 (-63.16%)
Mutual labels:  architecture, multiplatform
JsonPlaceholderApp
This was originally a code challenge for a company, but now is an example of MVI on Android.
Stars: ✭ 26 (-72.63%)
Mutual labels:  architecture
wxWidgetsTemplate
A template project for wxWidgets C++, with pre-set files and IDE projects, and allows for easy updates to wxWidgets
Stars: ✭ 13 (-86.32%)
Mutual labels:  native

Multiplatform LiveData

Réimplémentation of android LiveDatas on kotlin-multiplatform

It wraps reals livedatas on Android, and uses an Observable-Pattern on iOS

It works exactly the same as Android LiveDatas : https://developer.android.com/topic/libraries/architecture/livedata

KLiveData<T> Read only observable KMutableLiveData<T> Read / Write observable KMediatorLiveData<T> Read / Write observable, capable of listen KLiveData

Transformations like map and switchmap are available too

class MainViewModel(val premiumManager: PremiumManager) {
    private val _viewState = KMediatorLiveData<ViewState>()
    
    val viewState = KLiveData<ViewState>()
        get() = _viewState

    init {
        _viewState.value = ViewState("not premium")

        _viewState.addSource(premiumManager.premium()) {
            if(it) {
                _viewState.value = ViewState("premium")
            } else {
                _viewState.value = ViewState("not premium")
            }
        }
    }
}
class ViewState(
    val userStatus: String
)
class PremiumManager {
    private val premium = KMutableLiveData<Boolean>()
    fun premium() : KLiveData<Boolean> {
        return premium
    }

    fun becomePremium() {
        premium.value = true
    }

    init {
        //default value
        premium.value = false
    }
}

Download

Add the repository

repositories {
    maven { url  "https://dl.bintray.com/florent37/maven" }
}

common

Download

implementation "com.github.florent37:multiplatform-livedata:1.0.0"

ios

Download

Uses a kotlin reimplementation of livedatas

implementation "com.github.florent37:multiplatform-livedata-ios:1.0.0"

android

Uses inside the jetpack's LiveDatas

Download

implementation "com.github.florent37:multiplatform-livedata-android:1.0.0"

You can retrieve the real livedatas stored inside :

KLiveData<T>.toLivedata : LiveData<T>

KMutableLiveData<T>.toMutableLiveData : MutableLiveData<T>

KMediatorLiveData<T>.toMediatorLivedata : MediatorLivedata<T>

And create KLiveDatas from jetpacks LiveDatas

LiveData<T>.toKLivedata: KLiveData<T>

MutableLiveData<T>.toKMutableLiveData: KMutableLiveData<T>

MediatorLiveData<T>.toKMediatorLivedata: KMediatorLiveData<T>

License

Copyright 2018 Florent37

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].