在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):BracketCove/KotlinMVPCalculator开源软件地址(OpenSource Url):https://github.com/BracketCove/KotlinMVPCalculator开源编程语言(OpenSource Language):Kotlin 100.0%开源软件介绍(OpenSource Introduction):MVP Kotlin CalculatorThe primary goal of this project was to help me learn Kotlin, and to create a better implementation of MVP than I have in previous years, which includes a ViewModel object (not to be confused with MVVM). F.A.Q.Why use complicated libraries like RxJava for a simple project? I get this question quite a lot. It's quite simple really: They are all libraries which I have, and will continue to employ it my projects. They all have a reason, and the reason is never to scare anyone. RxJava 2 is used for concurrency. Yes, I could use LiveData, AsyncTask, and other options, but I would personally recommend RxJava 2 right now. Don't be one of those annoying people that message me because they're pissed off they can't understand how it works. Instead, just ask me and I'll be happy to try and help you learn :). We all started out not knowing. If this is MVP, what's with the ViewModel? In previous implementations, I would maintain temporary UI state either within my Fragment (View) or my Presenter (Presenter). This is problematic, as I don't think the View, nor the Presenter, should have anything to do with storing state. This necessitated another object in my Presentation Layer which could store view state without being tightly coupled to anything. I achieve this by having my Presenter delegate temporary state to the ViewModel. As per suggestion from my Brogrammer Darel Bitsy, the ViewModel uses a BehaviourSubject to pass fresh data to the Presenter, whenever the Presenter receives fresh data from the 'backend'. This allows the Presenter to not have to worry about asking the VM constantly for new data, reducing repetitious code. I like Hannes Dorfmann's opinion (if I'm not mistaken about it) that the "Model" is the "state" of the application, whether it needs to exist in the backend as a Database, or a temporary ViewModel similar to this project. So what I'm saying is, it's still MVP, it's just that I call one part of the Model as a 'ViewModel' for two reasons:
Architecture:
Sources and InspirationAwesome, Kotlin clean MVP open source Weather/News App by @darelbitsy: https://github.com/bitsydarel/DBWeather Awesome collection of projects made by pro devs and googlers: https://github.com/googlesamples/android-architecture Same as above, with emphasis on AAC things like ViewModel: https://github.com/googlesamples/android-architecture-components Martin Fowler (see his blog article called "Passive View"): https://martinfowler.com/ |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论