当前位置:网站首页>Practice of Android jetpack and kotlin coroutines

Practice of Android jetpack and kotlin coroutines

2020-12-06 08:09:28 InfoQ

{"type":"doc","content":[{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":" One 、 Preface "}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"1.1 Technical background and selection "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" since 2017 year Google IO Since the Congress , After three years of development ,Kotlin Has become Android The preferred development language for the platform . But compared to the language itself ,Kotlin 1.2 After the version, enter stable Coprogramming of States (coroutines) Industry adoption is still low ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" The main advantages of coprocess are :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" A simpler implementation of asynchronous concurrency ( It's similar to synchronous writing )"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" More convenient task management "}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" More convenient producers - Consumer model implementation "}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" More efficient cold stream Realization ( namely Flow, According to official figures ,Flow In part benchmarks In the scenario, the efficiency is RxJava Twice as many , See the reference link for details 1)."}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Google Android The team is also promoting Jetpack Component library , among AAC Architecture components bring a new way to implement application architecture , Can be more convenient to achieve MVVM This design pattern is very suitable for complex business scenarios ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"1.2 Business background "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" There is a big demand this year , On the product direction, I hope to try a new experience of platform search home page of traffic business integration . So the business R & D teams went through several rounds of technical evaluation , Decided to jointly launch the development of this new project . Take this opportunity to , Plane ticket App The team's decision is based on Android Jetpack AAC Component library and Kotlin Coroutines The technical solution is reconstructed to realize ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" The business logic of the ticket homepage can be summarized and abstracted into the following two scenarios :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1) Multiple differences View, Changes that depend on the same data source ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2) Multiple differences View, When the user operates , Will trigger changes to the same data source ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}}]}

版权声明
本文为[InfoQ]所创,转载请带上原文链接,感谢
https://chowdera.com/2020/12/20201206080900186p.html