Giter VIP home page Giter VIP logo

Comments (2)

dbaroncelli avatar dbaroncelli commented on June 4, 2024

Hi @jiqimaogou thanks for your feedback.

I think the most important concept is the separation between the ViewModel and Repository, which is present in all architectures. These are the main 2 blocks.
Specifically, the D-KMP Architecture is implementing the MVI pattern, which requires to organize the ViewModel in a certain way. The MVI pattern helps writing very simple code, but in order to do that you need to give a very neat structure.

The 4 elements in the KMPViewModel are simply:

  • Events, called by the UI layer to perform actions
  • StateProviders, called by the UI layer to get the state for each screen
  • StateReducers, where we define all functions that make modifications to the state (they are always called by the Events)
  • StateManager, this is the core class of the whole architecture. It provides a consistent mechanism to manage state initializations and coroutine scopes.

The 6 files you mentioned:
Events.kt
KMPViewModel.kt
StateManager.kt
StateProviders.kt
StateReducers.kt
Repository.kt

stay the same for each app. There is not really anything to maintain.

What you personalize in the shared code of each app, is just:

  • the 4 files (Events, State, StateProvider, StateReducers) in each screen folder in the ViewModel
  • the functions, objects and sources in the DataLayer

Feel free to provide more specific feedback on which further simplifications you think could be made.

app_structure

from d-kmp-sample.

jiqimaogou avatar jiqimaogou commented on June 4, 2024

ok, thank you. I think the answer is ok.

from d-kmp-sample.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.