官术网_书友最值得收藏!

Creating an asynchronous function to hold the request... or not

Currently, a big part of our code to request and display the number of news is inside the onCreate() function. This is less than optimal, not only because it's mixed with the creation of the activity, but also because it prevents reusing this code. For example, if there were to be a refresh button, we would need to reuse all the code of the coroutine.

When considering the separation of this coroutine into its own function, there are many possible approaches. Here, we will cover the most common ones.

主站蜘蛛池模板: 岫岩| 本溪市| 简阳市| 威信县| 枣庄市| 伊吾县| 简阳市| 格尔木市| 监利县| 邯郸县| 永丰县| 施秉县| 安国市| 祁东县| 壤塘县| 海原县| 三亚市| 科尔| 尼玛县| 洞口县| 朝阳区| 延川县| 梧州市| 开平市| 松滋市| 赤城县| 三原县| 象州县| 临沂市| 樟树市| 乌海市| 乌兰察布市| 宁德市| 泾川县| 广德县| 吐鲁番市| 炉霍县| 和林格尔县| 龙陵县| 沿河| 新郑市|