{"id":944,"date":"2026-01-25T06:53:28","date_gmt":"2026-01-25T06:53:28","guid":{"rendered":"https:\/\/nurlandroid.com\/?p=944"},"modified":"2026-01-25T06:53:30","modified_gmt":"2026-01-25T06:53:30","slug":"%d1%87%d1%82%d0%be-%d1%82%d0%b0%d0%ba%d0%be%d0%b5-flow-%d1%87%d0%b5%d0%bc-%d0%be%d1%82%d0%bb%d0%b8%d1%87%d0%b0%d0%b5%d1%82%d1%81%d1%8f-%d0%be%d1%82-sequence-%d0%b8-suspend-%d1%84%d1%83%d0%bd%d0%ba","status":"publish","type":"post","link":"https:\/\/nurlandroid.com\/?p=944","title":{"rendered":"\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Flow? \u0427\u0435\u043c \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 Sequence \u0438 Suspend-\u0444\u0443\u043d\u043a\u0446\u0438\u0438?"},"content":{"rendered":"\n<p><code>Flow<\/code> \u2014 \u044d\u0442\u043e \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0441\u0442\u0440\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Kotlin Coroutines, \u0430\u043d\u0430\u043b\u043e\u0433 <code>Rx<\/code>, \u043d\u043e \u0432 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u043d\u043e\u043c \u0441\u0442\u0438\u043b\u0435. \u0415\u0433\u043e \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u0438 \u0443\u043c\u0435\u0442\u044c \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c \u043e\u0442 <code>Sequence<\/code> \u0438 <code>suspend-\u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/code>.<\/p>\n\n\n\n<p><strong><code>Flow&lt;T><\/code><\/strong> \u2014 \u044d\u0442\u043e \u0442\u0438\u043f, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 <strong>\u043b\u0435\u043d\u0438\u0432\u044b\u0439 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 <strong>\u044d\u043c\u0438\u0442\u0438\u0442 (emit)<\/strong> \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 <strong>\u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438<\/strong>, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c <strong>\u043d\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044f<\/strong> \u043f\u043e\u0442\u043e\u043a.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nfun numbers(): Flow&amp;lt;Int&gt; = flow {\n    for (i in 1..3) {\n        emit(i)\n        delay(100) \/\/ \u043d\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u0442\u043e\u043a!\n    }\n}\n<\/pre><\/div>\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u041a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>Flow<\/code><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Cold<\/strong> (\u0445\u043e\u043b\u043e\u0434\u043d\u044b\u0439) \u2014 \u043d\u0435 \u043d\u0430\u0447\u043d\u0451\u0442 \u0440\u0430\u0431\u043e\u0442\u0443, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0430\u0447\u043d\u0451\u0448\u044c <code>collect<\/code><\/li>\n\n\n\n<li>\u0410\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439: <code>delay<\/code>, <code>network<\/code>, <code>db<\/code> \u0432\u043d\u0443\u0442\u0440\u0438 <code>flow {}<\/code> \u043d\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0442<\/li>\n\n\n\n<li>Structured concurrency: <code>flow<\/code> \u0436\u0438\u0432\u0451\u0442 \u0432 <code>CoroutineScope<\/code><\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u0427\u0435\u043c \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445?<\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435<\/th><th><code>suspend fun<\/code><\/th><th><code>Sequence<\/code><\/th><th><code>Flow<\/code><\/th><\/tr><\/thead><tbody><tr><td>\u041a\u043e\u043b-\u0432\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439<\/td><td>\u041e\u0434\u043d\u043e (<code>T<\/code>)<\/td><td>\u041c\u043d\u043e\u0433\u043e (<code>T<\/code>)<\/td><td>\u041c\u043d\u043e\u0433\u043e (<code>T<\/code>)<\/td><\/tr><tr><td>\u0410\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0441\u0442\u044c<\/td><td>\u0434\u0430 (\u043d\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442)<\/td><td>\u043d\u0435\u0442 (\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442)<\/td><td>\u0434\u0430 (\u043d\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442)<\/td><\/tr><tr><td>\u041e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u044c (lazy)<\/td><td>\u043d\u0435\u0442<\/td><td>\u0434\u0430<\/td><td>\u0434\u0430<\/td><\/tr><tr><td>\u041f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435<\/td><td>\u0427\u0435\u0440\u0435\u0437 <code>cancel()<\/code> scope<\/td><td>\u043d\u0435\u043b\u044c\u0437\u044f<\/td><td>\u0447\u0435\u0440\u0435\u0437 <code>collect<\/code> \u0438\u043b\u0438 scope<\/td><\/tr><tr><td>Backpressure<\/td><td>\u043d\u0435\u0442<\/td><td>\u043d\u0435\u0442<\/td><td>\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u0427\u0430\u0441\u0442\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0438 Flow<\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u041e\u0448\u0438\u0431\u043a\u0430<\/th><th>\u041f\u043e\u0447\u0435\u043c\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/th><\/tr><\/thead><tbody><tr><td><code>flow.collect {}<\/code> \u0432 UI \u0431\u0435\u0437 \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0430<\/td><td>\u041c\u043e\u0436\u0435\u0442 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c UI<\/td><\/tr><tr><td><code>collect()<\/code> \u0431\u0435\u0437 <code>launch<\/code> \u0432 ViewModel<\/td><td>\u0411\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 suspend-\u0444\u0443\u043d\u043a\u0446\u0438\u044e<\/td><\/tr><tr><td><code>collect()<\/code> \u0432\u043d\u0435 \u0441\u043a\u043e\u0443\u043f\u0430<\/td><td>\u041f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u0443\u0442\u0435\u0447\u043a\u0435 \u0438\u043b\u0438 \u043f\u0430\u0434\u0435\u043d\u0438\u044e<\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Flow \u2014 \u044d\u0442\u043e \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0441\u0442\u0440\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Kotlin Coroutines, \u0430\u043d\u0430\u043b\u043e\u0433 Rx, \u043d\u043e \u0432 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u043d\u043e\u043c \u0441\u0442\u0438\u043b\u0435. \u0415\u0433\u043e \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u0438 \u0443\u043c\u0435\u0442\u044c \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c \u043e\u0442 Sequence \u0438 suspend-\u0444\u0443\u043d\u043a\u0446\u0438\u0439. Flow&lt;T> \u2014 \u044d\u0442\u043e \u0442\u0438\u043f, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u043b\u0435\u043d\u0438\u0432\u044b\u0439 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044d\u043c\u0438\u0442\u0438\u0442 (emit) \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044f \u043f\u043e\u0442\u043e\u043a. \u041a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 Flow \u0427\u0435\u043c \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445? \u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 suspend [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,21],"tags":[],"class_list":["post-944","post","type-post","status-publish","format-standard","hentry","category-coroutines","category-kotlin"],"_links":{"self":[{"href":"https:\/\/nurlandroid.com\/index.php?rest_route=\/wp\/v2\/posts\/944","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nurlandroid.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nurlandroid.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nurlandroid.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nurlandroid.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=944"}],"version-history":[{"count":1,"href":"https:\/\/nurlandroid.com\/index.php?rest_route=\/wp\/v2\/posts\/944\/revisions"}],"predecessor-version":[{"id":945,"href":"https:\/\/nurlandroid.com\/index.php?rest_route=\/wp\/v2\/posts\/944\/revisions\/945"}],"wp:attachment":[{"href":"https:\/\/nurlandroid.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=944"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nurlandroid.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=944"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nurlandroid.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=944"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}