Skip to content
/ mvi-demo Public

Sample To-Do app built with MVI pattern for Android

License

Notifications You must be signed in to change notification settings

psuzn/mvi-demo

Repository files navigation

ToDo Sample App

Todo sample app built with MVI .

License

  

MVI Pattern


Fig. MVI in Nutshell [image](https://medium.com/@thanh.bm/android-mvi-architecture-with-livedata-c72e9e1bd3e6)

Single Event Management

The single event management in mvi has always been a debatable question. I'm using this simple class to handle single event.

class SingleEvent<T>(value: T? = null) {
    private var _value: T? = null

    val value: T?
        get() {
            val tmp = _value;
            _value = null
            return tmp
        }

    init {
        _value = value
    }
}

And I'm using it as:

data class UIState(toast:SingleEvent<String>) // state class


stateRelay.subscribe{state-> // state observable

    state.toast.value?.let{ showToast(it) }

}

Useful Resources

Bugs and Feedback

I made this app while I was playing around with mvi pattern. I am by no means expert and this implementation is not perfect.

For bugs, questions and discussions please use the Github Issues.

License

Copyright 2020 @psuzn

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.

About

Sample To-Do app built with MVI pattern for Android

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages