Giter Site home page Giter Site logo

Comments (4)

qingmei2 avatar qingmei2 commented on May 1, 2024 1

@RoyGuanyu

嗯嗯,如果实际项目不考虑Kodein,完全可以忽略它哈,因为这个项目毕竟是练手的项目,实际开发中项目的复杂度是远远超过这个repo的,因此技术选型还是需要慎重,这个repo的目的还是展示MVVM基本的实现方式和思路。

from mvvm-architecture.

qingmei2 avatar qingmei2 commented on May 1, 2024

@RoyGuanyu

这种情况下,你只需要额外声明一个ViewModel,然后通过ViewModel本身的特性,让多个Fragment共享一个ViewModel的实例即可。

个人经验来讲,这种ViewModel复用共享的情况,首先一定要给ViewModel中添加一定的注释,保证代码的可读性(对于整个team而言),其次,该ViewModel的职责要尽量单一,尽量避免一个巨大的BaseShareViewModel这种,导致未来某个版本需求变更导致代码修改幅度大的情况

from mvvm-architecture.

RoyGuanyu avatar RoyGuanyu commented on May 1, 2024

@ qingmei2了解,感谢回复〜
这边其实比较困惑是DI Kodein的部分,以这个项目为例,就是在 MainActivity 的 KodeinModule 中注册此ActivityWide 的 ViewModel,接着在其中的任何 Fragments 透过 closestKodein 来取得 Activity 注入的 viewmodel instance ,然后接下来进行 Activity 生命周期级别的数据操作。

from mvvm-architecture.

RoyGuanyu avatar RoyGuanyu commented on May 1, 2024

了解,但已经入坑XDDD 感谢指教 哈

from mvvm-architecture.

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.