{"id":948,"date":"2026-01-25T07:19:40","date_gmt":"2026-01-25T07:19:40","guid":{"rendered":"https:\/\/nurlandroid.com\/?p=948"},"modified":"2026-01-25T07:19:42","modified_gmt":"2026-01-25T07:19:42","slug":"%d1%85%d0%be%d0%bb%d0%be%d0%b4%d0%bd%d1%8b%d0%b5-vs-%d0%b3%d0%be%d1%80%d1%8f%d1%87%d0%b8%d0%b5-%d0%bf%d0%be%d1%82%d0%be%d0%ba%d0%b8-%d0%be%d0%b1%d1%8a%d1%8f%d1%81%d0%bd%d0%b8-%d0%bd%d0%b0","status":"publish","type":"post","link":"https:\/\/nurlandroid.com\/?p=948","title":{"rendered":"\u0425\u043e\u043b\u043e\u0434\u043d\u044b\u0435 vs \u0433\u043e\u0440\u044f\u0447\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u2014 \u043e\u0431\u044a\u044f\u0441\u043d\u0438 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445"},"content":{"rendered":"\n<p>\u0420\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 <strong>\u0445\u043e\u043b\u043e\u0434\u043d\u044b\u0435 (cold)<\/strong> \u0438 <strong>\u0433\u043e\u0440\u044f\u0447\u0438\u0435 (hot)<\/strong> \u043f\u043e\u0442\u043e\u043a\u0438 \u2014 \u044d\u0442\u043e <strong>\u043e\u0434\u043d\u0430 \u0438\u0437 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0439<\/strong> \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e\/\u043a\u043e\u0440\u0443\u0442\u0438\u043d-\u0444\u043b\u043e\u0443\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><\/th><th>\u0425\u043e\u043b\u043e\u0434\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a (<code>cold<\/code>)<\/th><th>\u0413\u043e\u0440\u044f\u0447\u0438\u0439 \u043f\u043e\u0442\u043e\u043a (<code>hot<\/code>)<\/th><\/tr><\/thead><tbody><tr><td>\u041a\u043e\u0433\u0434\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f<\/td><td>\u041f\u0440\u0438 <strong>\u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0435<\/strong> (<code>collect()<\/code>)<\/td><td>\u041d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f <strong>\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432<\/strong><\/td><\/tr><tr><td>\u041f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435<\/td><td>\u041a\u0430\u0436\u0434\u044b\u0439 <code>collector<\/code> \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 <strong>\u0441\u0432\u043e\u0438 \u0434\u0430\u043d\u043d\u044b\u0435<\/strong><\/td><td>\u0412\u0441\u0435 <code>collectors<\/code> \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 <strong>\u043e\u0434\u043d\u043e \u043e\u0431\u0449\u0435\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435<\/strong><\/td><\/tr><tr><td>\u041f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/td><td>\u041a\u0430\u043a <strong>\u0444\u0430\u0431\u0440\u0438\u043a\u0430<\/strong>: &#171;\u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0438\u0435\u043d\u0442 \u2014 \u043d\u043e\u0432\u0430\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f&#187;<\/td><td>\u041a\u0430\u043a <strong>\u0440\u0430\u0434\u0438\u043e<\/strong>: &#171;\u0438\u0434\u0451\u0442 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e, \u0441\u043b\u0443\u0448\u0430\u0435\u0448\u044c \u2014 \u0441\u043b\u044b\u0448\u0438\u0448\u044c&#187;<\/td><\/tr><tr><td>\u041f\u0440\u0438\u043c\u0435\u0440\u044b<\/td><td><code>flow {}<\/code>, <code>flowOf()<\/code>, <code>Sequence<\/code><\/td><td><code>StateFlow<\/code>, <code>SharedFlow<\/code>, <code>LiveData<\/code>, <code>callback<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0438<\/h4>\n\n\n\n<p>Cold (<code>flow<\/code>) => \u0417\u0430\u043a\u0430\u0437 \u0435\u0434\u044b \u0432 \u043a\u0430\u0444\u0435: \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u0432\u043e\u044e \u043f\u043e\u0440\u0446\u0438\u044e<\/p>\n\n\n\n<p><strong>Hot (<code>stateFlow<\/code>)<\/strong> => \u0422\u0430\u0431\u043b\u043e \u0432 \u0430\u044d\u0440\u043e\u043f\u043e\u0440\u0442\u0443: \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f, \u0442\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043c\u043e\u0442\u0440\u0438\u0448\u044c<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u041f\u0440\u0438\u043c\u0435\u0440 \u0445\u043e\u043b\u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 &#8212; Flow<\/h4>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nfun coldFlow(): Flow&amp;lt;Int&gt; = flow {\n    println(&quot;Flow started&quot;)\n    emit(1)\n    emit(2)\n}\n\nrunBlocking {\n    coldFlow().collect { println(&quot;C1: $it&quot;) }\n    coldFlow().collect { println(&quot;C2: $it&quot;) }\n}\n<\/pre><\/div>\n\n\n<p><strong>\u0412\u044b\u0432\u043e\u0434:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nFlow started\nC1: 1\nC1: 2\nFlow started\nC2: 1\nC2: 2\n<\/pre><\/div>\n\n\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043f\u043e\u0442\u043e\u043a <strong>\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u043d\u043e\u0432\u043e<\/strong> \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0435 \u0438 <code>collect()<\/code> \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 producer.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u041f\u0440\u0438\u043c\u0435\u0440 \u0433\u043e\u0440\u044f\u0447\u0435\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 \u2014 <code>StateFlow<\/code><\/h4>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nval state = MutableStateFlow(0)\n\nstate.value = 1\nstate.value = 2\nstate.value = 3\n\nstate.collect { println(it) } \/\/ \u0443\u0432\u0438\u0434\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u0435\n<\/pre><\/div>\n\n\n<p>\u0412\u044b\u0432\u043e\u0434:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n3 \/\/ \u0443\u0432\u0438\u0434\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u0435\n<\/pre><\/div>\n\n\n<p>\u041f\u043e\u043c\u043d\u0438\u0442\u0435 \u0447\u0442\u043e, Producer \u0443\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043b\u0438\u0441\u044c. Subscriber \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 <strong>\u0442\u043e\u043b\u044c\u043a\u043e \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/strong>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0420\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 \u0445\u043e\u043b\u043e\u0434\u043d\u044b\u0435 (cold) \u0438 \u0433\u043e\u0440\u044f\u0447\u0438\u0435 (hot) \u043f\u043e\u0442\u043e\u043a\u0438 \u2014 \u044d\u0442\u043e \u043e\u0434\u043d\u0430 \u0438\u0437 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0439 \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e\/\u043a\u043e\u0440\u0443\u0442\u0438\u043d-\u0444\u043b\u043e\u0443\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0425\u043e\u043b\u043e\u0434\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a (cold) \u0413\u043e\u0440\u044f\u0447\u0438\u0439 \u043f\u043e\u0442\u043e\u043a (hot) \u041a\u043e\u0433\u0434\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u041f\u0440\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0435 (collect()) \u041d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432 \u041f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u041a\u0430\u0436\u0434\u044b\u0439 collector \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u0432\u043e\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0412\u0441\u0435 collectors \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u043e\u0434\u043d\u043e \u043e\u0431\u0449\u0435\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u041f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u041a\u0430\u043a \u0444\u0430\u0431\u0440\u0438\u043a\u0430: &#171;\u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0438\u0435\u043d\u0442 \u2014 \u043d\u043e\u0432\u0430\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f&#187; \u041a\u0430\u043a \u0440\u0430\u0434\u0438\u043e: &#171;\u0438\u0434\u0451\u0442 [&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-948","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\/948","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=948"}],"version-history":[{"count":1,"href":"https:\/\/nurlandroid.com\/index.php?rest_route=\/wp\/v2\/posts\/948\/revisions"}],"predecessor-version":[{"id":950,"href":"https:\/\/nurlandroid.com\/index.php?rest_route=\/wp\/v2\/posts\/948\/revisions\/950"}],"wp:attachment":[{"href":"https:\/\/nurlandroid.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=948"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nurlandroid.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=948"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nurlandroid.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=948"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}