Helium一个采用100%Kotlin编写的Android轻量级MVP框架

网友投稿 632 2022-10-30

Helium一个采用100%Kotlin编写的Android轻量级MVP框架

Helium一个采用100%Kotlin编写的Android轻量级MVP框架

Helium

Lightweight & intuitive framework for Android. 100% Kotlin.

What if building an App was as simple as assembling Lego blocks?

Download

implementation 'com.joaquimverges.helium:helium-core:x.y.z' // core classesimplementation 'com.joaquimverges.helium:helium-ui:x.y.z' // ui componentsimplementation 'com.joaquimverges.helium:helium-navigation:x.y.z' // navigation componentstestImplementation 'com.joaquimverges.helium:helium-test:x.y.z' // unit test helper classes

Documentation

Core framework Helium UI Helium Navigation Helium Testing

Overview

An intuitive architecture pattern

Building an app should feel like assembling Lego blocks, that's the core principle of Helium. The framework proposes the following mental model to structure your code:

UiBlock - a class that handles rendering UI.LogicBlock - a class that handles logic.AppBlock = (LogicBlock + UiBlock) - assembling logic with UI creates a fully functional piece of your App.

Just like Lego blocks, or puzzle pieces, a UiBlock can only be assembled with a LogicBlock if they're compatible.

In code, this is handled by two classes representing the connectors between blocks: BlockState and BlockEvent

a LogicBlock exposes (emits) a BlockState and expects (handles) a BlockEventa UiBlock exposes (emits) a BlockEvent and expects (renders) a BlockState

If both Logic and UI expose and expect the same type of state and event, then they're compatible.

With an intuitive, kotlin first API, assembling blocks in Activity or Fragment is as simple as this:

val logic = MyLogic() // create a logic blockval ui = MyUi(layoutInflater) // create a UI blockassemble(logic + ui) // assemble them

For detailed information and examples, head over to the helium-core documentation.

Ready to use App Blocks

Helium provides the framework to build your own AppBlocks, but also provides a growing catalog of existing blocks ready to be used:

helium-ui: List, Cards, ViewPager, etc.helium-navigation: Collapsing Toolbar, Bottom Navigation, Drawer, etc.

Here's a typical usage of ListUi, one of the most useful blocks provided.

val listUi = ListUi(layoutInflater, { inflater, container -> MyListItem(inflater, container)})assemble(MyListLogic() + listUi)

Follow the links above for documentation and examples on how to use those handy App Blocks in your own apps.

Samples

newsapp - Fully functional News app downloadable on Google Playdemoapp - A catalog of different AppBlocks usages

Testing

Unit testing blocks is easy, and you should always write tests for your LogicBlock when possible. Helium provides helper classes to make testing your logic super simple. Head over to the helium-test documentation to learn more.

License

Copyright (C) 2020 Joaquim VergesLicensed 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://apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed 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 andlimitations under the License.

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Dubbo基础入门介绍
下一篇:SpringBoot接口 - 如何生成接口文档之非侵入方式(通过注释生成)Smart-Doc?
相关文章

 发表评论

暂时没有评论,来抢沙发吧~