{"id":399580,"date":"2024-06-29T14:45:24","date_gmt":"2024-06-29T14:45:24","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=399580"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=399580","title":{"rendered":"<span>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Unidirectional Data Flow \u0432 \u0441\u0443\u043f\u0435\u0440\u0430\u043f\u043f\u0435. \u0427\u0430\u0441\u0442\u044c II<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/company\/indriver\/blog\/571394\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u044f\u00a0\u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043b \u043d\u0430\u0448\u0443 \u0433\u043b\u0430\u0432\u043d\u0443\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043f\u0440\u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 Unidirectional Data Flow (UDF)\u00a0\u2014 \u043c\u043e\u0434\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044e. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043d\u043e\u0433\u043e UDF-\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u043d\u0430\u00a0Swift, \u043d\u043e\u00a0\u043c\u0430\u043b\u043e \u043a\u0442\u043e \u0443\u0442\u043e\u0447\u043d\u044f\u0435\u0442, \u043a\u0430\u043a \u0438\u0445\u00a0\u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u00a0\u0431\u043e\u043b\u044c\u0448\u043e\u0435, \u043c\u043d\u043e\u0433\u043e\u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u0412\u043e\u00a0\u0432\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u044f\u00a0\u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f, \u0441\u00a0\u043a\u0430\u043a\u0438\u043c\u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043c\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0438\u00a0\u043a\u00a0\u043a\u0430\u043a\u0438\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u043c \u043f\u0440\u0438\u0448\u043b\u0438.<\/p>\n<p>\u0412\u00a0\u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c 3\u00a0\u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0438\u00a0\u0441\u0440\u0430\u0432\u043d\u0438\u043c, \u043a\u0430\u043a \u0440\u0430\u0437\u043d\u044b\u0435 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438 \u0438\u0445\u00a0\u0440\u0435\u0448\u0430\u044e\u0442. \u0414\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u044f\u00a0\u0432\u044b\u0431\u0440\u0430\u043b \u043e\u0434\u043d\u0438 \u0438\u0437\u00a0\u0441\u0430\u043c\u044b\u0445 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u2014 <a href=\"https:\/\/github.com\/ReSwift\/ReSwift\"><u>ReSwift<\/u><\/a> \u0438 <a href=\"https:\/\/github.com\/pointfreeco\/swift-composable-architecture\"><u>The Composable Architecture<\/u><\/a> (TCA). \u0412\u00a0\u043a\u043e\u043d\u0446\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043c\u044b\u00a0\u0432\u00a0\u0438\u0442\u043e\u0433\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438. \u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c!<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5d4\/a12\/23d\/5d4a1223d7b222025f519c4f2eadfa0f.png\" width=\"1560\" height=\"880\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5d4\/a12\/23d\/5d4a1223d7b222025f519c4f2eadfa0f.png\"\/><figcaption><\/figcaption><\/figure>\n<h2>3 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043c\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c <\/h2>\n<p><strong>1. \u0412\u0441\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0437\u043d\u0430\u044e\u0442 \u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/strong><\/p>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0435\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438\u00a0\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0432\u00a0\u043d\u0435\u043c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u043b\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u00a0\u0437\u0430\u043a\u0430\u0437\u0435. \u0423\u00a0\u044d\u0442\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0435\u0441\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043b\u0435\u0436\u0438\u0442 \u0432\u00a0AppState. \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0437\u043d\u0430\u0435\u0442 \u043e\u0431\u00a0AppState, \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u00a0\u043d\u0435\u0433\u043e \u0438\u00a0\u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430\u00a0\u044d\u043a\u0440\u0430\u043d:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/2c1\/7e7\/897\/2c17e78976baba8f8865426ed9124342.jpg\" width=\"1920\" height=\"1080\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2c1\/7e7\/897\/2c17e78976baba8f8865426ed9124342.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0430\u043a\u0438\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0432\u00a0\u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0438\u00a0\u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437\u00a0\u043d\u0438\u0445 \u0437\u043d\u0430\u0435\u0442 \u043e\u0431\u00a0AppState. \u042d\u0442\u043e \u043f\u043b\u043e\u0445\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0430\u0440\u0443\u0448\u0430\u0435\u0442 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%97%D0%B0%D0%BA%D0%BE%D0%BD_%D0%94%D0%B5%D0%BC%D0%B5%D1%82%D1%80%D1%8B\"><u>\u0417\u0430\u043a\u043e\u043d \u0414\u0435\u043c\u0435\u0442\u0440\u044b<\/u><\/a>. \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u043d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 State, \u043d\u043e\u00a0\u0438\u043c\u00a0\u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0441\u043a\u0432\u043e\u0437\u044c AppState \u043a\u00a0\u0441\u0432\u043e\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u043c. \u0427\u0430\u0441\u0442\u043e \u0432\u00a0\u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u0435\u043c \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434:\u00a0 <\/p>\n<pre><code class=\"swift\">let state = appState.someInnerState.anotherInnerState.andAnotherOneState.finallyMyState<\/code><\/pre>\n<p>\u041f\u0438\u0441\u0430\u0442\u044c \u0438\u00a0\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u043a\u0440\u0430\u0439\u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e, \u0445\u043e\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0438\u00a0\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0421\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b\u00a0\u0437\u0430\u0445\u043e\u0442\u0438\u043c \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0432\u00a0\u0434\u0440\u0443\u0433\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0435\u0433\u043e \u0432\u00a0\u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/108\/03f\/861\/10803f861936a7cb8a6629b72ff87f7e.jpg\" width=\"1920\" height=\"1080\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/108\/03f\/861\/10803f861936a7cb8a6629b72ff87f7e.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0440\u0430\u0437\u0443 2 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b:<\/p>\n<ol>\n<li>\n<p>App1 \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043f\u0440\u043e Component, \u0447\u0442\u043e\u0431\u044b \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. Component \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043f\u0440\u043e App1, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a AppState. \u041c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438, \u0447\u0442\u043e \u043d\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u0449\u0438\u043a\u0443 Swift.<\/p>\n<\/li>\n<li>\n<p>Component \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043f\u0440\u043e App2, \u0430 \u0432 \u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u0435 \u0438 \u043e App3, App4 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.<\/p>\n<\/li>\n<\/ol>\n<p>\u0420\u0435\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043c\u043e\u0436\u043d\u043e, \u0437\u0430\u0431\u0440\u0430\u0432 State \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0432\u043d\u0443\u0442\u0440\u044c \u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/8cc\/a4c\/0fc\/8cca4c0fcafa31d829f307a791b1a30f.jpg\" width=\"1920\" height=\"1080\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8cc\/a4c\/0fc\/8cca4c0fcafa31d829f307a791b1a30f.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0434\u0443\u043b\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043d\u0438\u00a0\u043e\u00a0\u043a\u043e\u043c \u043d\u0435\u00a0\u0437\u043d\u0430\u0435\u0442 \u0438\u00a0\u043d\u0435\u00a0\u0438\u043c\u0435\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439. \u0421\u0430\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0437\u043d\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u00a0\u0441\u0432\u043e\u0435\u043c \u0441\u0442\u0435\u0439\u0442\u0435. \u041c\u043e\u0434\u0443\u043b\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0437\u043d\u0430\u044e\u0442 \u043e\u00a0\u043c\u043e\u0434\u0443\u043b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u0438\u00a0AppState \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437\u00a0\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 State \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0438\u0437\u00a0\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f. \u041e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0443\u0447\u0438\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0441\u043b\u0443\u0448\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0443\u00a0\u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0435\u0439\u0442\u0430, \u0432\u00a0\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d\u00a0\u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043d. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u044d\u0442\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u0432\u00a0\u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430\u0445.<\/p>\n<p><strong>ReSwift<\/strong>. ReSwift \u0438\u0434\u0435\u0442 \u043f\u043e\u00a0\u043f\u0443\u0442\u0438 \u0441\u0432\u043e\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u0448\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0438\u043a\u0430 \u0438\u00a0\u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u0441\u0445\u043e\u0436\u0438\u0439\u00a0\u0441 <a href=\"https:\/\/redux.js.org\/usage\/deriving-data-selectors\"><u>c\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u0430\u043c\u0438 \u0438\u0437 Redux<\/u><\/a>. \u041f\u043e\u0434\u043f\u0438\u0441\u043a\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u0430 \u0431\u044b \u0442\u0430\u043a:<\/p>\n<pre><code class=\"swift\">store.subscribe(self) { $0.select { $0.componentState } }<\/code><\/pre>\n<p>\u0421\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u044b \u0432\u00a0Redux\u00a0\u2014 \u043c\u043e\u0449\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0441\u00a0\u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <a href=\"https:\/\/github.com\/reduxjs\/reselect\">reselect<\/a>. \u0412\u00a0ReSwift \u0442\u0430\u043a\u043e\u0439\u00a0\u0436\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0441\u043b\u0438 \u043f\u043e\u0441\u043b\u0435 \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438 Action \u0441\u0442\u0435\u0439\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043d\u0435\u00a0\u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f, \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043d\u0435\u00a0\u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0442\u043e\u0442\u00a0\u0436\u0435 \u0441\u0442\u0435\u0439\u0442 \u0435\u0449\u0435 \u0440\u0430\u0437.<\/p>\n<p><strong>TCA. <\/strong>\u0423\u00a0TCA \u0432\u00a0Store \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434 scope. \u041e\u043d\u00a0\u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0439 Store \u0441\u00a0\u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u044c\u044e \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438:<\/p>\n<pre><code class=\"swift\">let componentStore = store.scope(state: \\.componentState) \/\/ componentStore \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f Store&lt;ComponentState><\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430\u0448 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043d\u0430\u00a0componentStore. \u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043c\u044b\u00a0\u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0443 scope \u0432\u00a0\u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0442\u0440\u0435\u0442\u044c\u0435\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. TCA, \u043a\u0430\u043a \u0438\u00a0ReSwift, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0441\u0442\u0435\u0439\u0442\u044b, \u043d\u043e\u00a0\u0441\u00a0\u043f\u043e\u043c\u043e\u0449\u044c\u044e Combine\u00a0\u0438 <a href=\"https:\/\/developer.apple.com\/documentation\/combine\/fail\/removeduplicates()\"><u>removeduplicates()<\/u><\/a>.<\/p>\n<p><strong>inDriver UDF. <\/strong>\u041c\u044b\u00a0\u043f\u043e\u0448\u043b\u0438 \u043f\u043e\u00a0\u043f\u0440\u043e\u0441\u0442\u043e\u043c\u0443 \u043f\u0443\u0442\u0438 \u0438\u00a0\u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 KeyPath \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432\u00a0\u043c\u0435\u0442\u043e\u0434 connect:<\/p>\n<pre><code class=\"swift\">component.connect(to: store, state: \\.componentState)<\/code><\/pre>\n<p>\u041f\u043e\u043a\u0430 \u043c\u044b\u00a0\u043d\u0435\u00a0\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u043e\u0432 \u0441\u0442\u0435\u0439\u0442\u0430 (\u043e\u043d\u0430\u00a0\u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0432\u00a0\u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0442\u0440\u0435\u0442\u044c\u0435\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b). \u0417\u0430\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432\u00a0\u043c\u0435\u0442\u043e\u0434 connect \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043d\u0430\u00a0\u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u044b View-\u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043d\u0435\u00a0\u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c 2 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 View-\u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u043e\u0434\u0440\u044f\u0434. \u041f\u0440\u0430\u0432\u0434\u0430, \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c View-\u043c\u043e\u0434\u0435\u043b\u044c \u0435\u0449\u0435 \u0440\u0430\u0437.<\/p>\n<p><strong>2.<\/strong> <strong>2 \u043c\u043e\u0434\u0443\u043b\u044f \u0445\u043e\u0442\u044f\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u0444\u0438\u0447\u0443.<\/strong><\/p>\n<p><a class=\"anchor\" name=\"%D0%B4%D0%B2%D0%B0%20%D0%BC%D0%BE%D0%B4%D1%83%D0%BB%D1%8F\" id=\"\u0434\u0432\u0430 \u043c\u043e\u0434\u0443\u043b\u044f\"><\/a><\/p>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0435\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0444\u0438\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b\u00a0\u0445\u043e\u0442\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u00a02\u00a0\u043c\u043e\u0434\u0443\u043b\u044f\u0445. \u041e\u0431\u0430 \u043c\u043e\u0434\u0443\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432\u00a0\u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438. \u041b\u043e\u0433\u0438\u0447\u043d\u043e, \u0447\u0442\u043e \u0441\u0442\u0435\u0439\u0442 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437\u00a0\u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u0442\u0435\u0439\u0442 \u043f\u0440\u043e\u0444\u0438\u043b\u044f, \u0430\u00a0AppState \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u00a0\u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u0438\u00a0\u043f\u0440\u043e\u0444\u0438\u043b\u044f:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/6c1\/e62\/5ea\/6c1e625eaf1644fbed82480be90cdae1.jpg\" width=\"1920\" height=\"1550\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6c1\/e62\/5ea\/6c1e625eaf1644fbed82480be90cdae1.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412\u00a0\u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b\u00a0\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043a\u043e\u043f\u0438\u0438 ProfileState \u0432\u00a03\u00a0\u043c\u0435\u0441\u0442\u0430\u0445: AppState, Feature1State \u0438\u00a0Feature2State. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u00a0\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043e\u0434\u0438\u043d, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u00a0ProfileState \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0432\u00a0\u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0435. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c Feature1 \u0438\u00a0Feature2 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u043c\u0435\u0442\u044c \u0432\u00a0\u0441\u0432\u043e\u0438\u0445 \u0441\u0442\u0435\u0439\u0442\u0430\u0445 ProfileState, \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a\u00a0AppState \u043e\u043d\u0438 \u043d\u0435\u00a0\u0438\u043c\u0435\u044e\u0442. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c 2\u00a0\u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b\u00a0\u0443\u0441\u043b\u043e\u0432\u043d\u043e \u043d\u0430\u0437\u0432\u0430\u043b\u0438 <strong>Computed Module State <\/strong>\u0438 <strong>State Protocol and Where Clause<\/strong>:<\/p>\n<p><strong>Computed Module State. <\/strong>\u0420\u0430\u0437\u0434\u0435\u043b\u0438\u043c FeatureState \u043d\u0430\u00a02\u00a0\u0447\u0430\u0441\u0442\u0438. \u041d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e FeatureState\u00a0\u2014 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u0439 \u0444\u0438\u0447\u0435. \u0418\u00a0FeatureModuleState\u00a0\u2014 FeatureState + \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0441\u0442\u0435\u0439\u0442\u044b:<\/p>\n<pre><code class=\"swift\">struct FeatureModuleState {     let feature: FeatureState     let profile: ProfileState }<\/code><\/pre>\n<p>\u0422\u043e\u0433\u0434\u0430 \u0432 AppState \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e FeatureState \u0438 ProfileState:<\/p>\n<pre><code class=\"swift\">struct AppState {     let feature1: Feature1State     let feature2: Feature2State     let profile: ProfileState }<\/code><\/pre>\n<p>ModuleState \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043a\u0430\u043a \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430:<\/p>\n<pre><code class=\"swift\">extension AppState {     var feature1Module: Feature1ModuleState {         .init(feature: feature1, profile: profile)     }   var feature2Module: Feature2ModuleState {     .init(feature: feature2, profile: profile) } }<\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u0430\u043a\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/c71\/3bc\/cf2\/c713bccf2e2bdfef5b1197c31d266ebe.jpg\" width=\"1920\" height=\"1550\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c71\/3bc\/cf2\/c713bccf2e2bdfef5b1197c31d266ebe.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430\u00a0\u0443\u0440\u043e\u0432\u043d\u0435 AppState \u043c\u044b\u00a0\u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u043c, \u0447\u0442\u043e ProfileState \u0432\u00a0\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u00a0\u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0435. ModuleState\u00a0\u0436\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u0432\u043e\u0439 \u043f\u043e\u0434 \u043a\u0430\u0436\u0434\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c. \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043b\u0435\u0433\u043a\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0434 \u043b\u044e\u0431\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0444\u0438\u0447, \u043d\u043e\u00a0\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u043c\u043e\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043f\u043e\u0434 \u043a\u0430\u0436\u0434\u0443\u044e \u043d\u043e\u0432\u0443\u044e \u0444\u0438\u0447\u0443.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0435\u0441\u0442\u044c \u0432 \u0443\u0447\u0435\u0431\u043d\u044b\u0445 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430\u0445 TCA (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"https:\/\/github.com\/pointfreeco\/episode-code-samples\/blob\/main\/0073-modular-state-management-view-state\/PrimeTime\/PrimeTime\/ContentView.swift\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a>). \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 PrimeModelState \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u043c\u044b\u043c \u0438 \u043d\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 AppState.<\/p>\n<p><strong>State Protocol and Where Clause. <\/strong>\u0412\u043c\u0435\u0441\u0442\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u043c\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u044b. \u041e\u0431\u044a\u044f\u0432\u0438\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b Feature1ModuleState \u0438\u00a0\u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0435\u0433\u043e \u0432\u00a0AppState:<\/p>\n<pre><code class=\"swift\">protocol Feature1ModuleState {     let feature: Feature1State     let protifle: ProfileState } extension AppState: Feature1ModuleState {}<\/code><\/pre>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0434\u043b\u044f Feature2. \u0422\u0435\u043f\u0435\u0440\u044c \u0444\u0438\u0447\u0438 \u043c\u043e\u0433\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0443\u00a0\u0441\u0435\u0431\u044f FeatureModuleState \u0438\u00a0\u043d\u0435\u00a0\u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e AppState \u0438\u0445\u00a0\u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442. \u041d\u043e\u00a0\u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u00a0\u2014 \u0432\u00a0Swift <a href=\"https:\/\/forums.swift.org\/t\/covariance-contravariance\/39635\"><u>\u043a\u043e\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u044c<\/u><\/a> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c Store&lt;AppState> \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a Store&lt;FeatureModuleState>. \u0417\u0430\u0442\u043e \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u0434\u0430\u0442\u044c FeatureModuleState \u043a\u0430\u043a \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430:<\/p>\n<pre><code class=\"swift\">class FeatureViewController&lt;S: StoreType>: UIViewController where S.State: FeatureModuleState { let store: S init(store: S) {   self.store = store super.init(nibName: nil, bundle: nil)   } } <\/code><\/pre>\n<p>\u0418\u0437 \u043f\u043b\u044e\u0441\u043e\u0432 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0432\u044b\u0434\u0435\u043b\u0438\u043c \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u043c\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u0445, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b. \u041c\u0438\u043d\u0443\u0441 \u2014 \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u043a Generic \u043d\u0430 Store \u0441 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435\u043c, \u0447\u0442\u043e \u0435\u0433\u043e State \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 FeatureModuleState. \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0438 \u043c\u043e\u0434\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0438 <a href=\"https:\/\/github.com\/ReSwift\/ReSwift\/issues\/377#issuecomment-434364649\"><u>ReSwift<\/u><\/a>.<\/p>\n<p>\u0414\u043b\u044f \u0441\u0435\u0431\u044f \u043c\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 <strong>Computed Module State <\/strong>\u043a\u0430\u043a \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0438 \u043d\u0435 \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e\u0449\u0435\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/p>\n<p><strong>3.<\/strong> <strong>\u041f\u043e\u0434\u043f\u0438\u0441\u043a\u0430 \u043d\u0430 Store \u0432\u043d\u0443\u0442\u0440\u0438 \u043c\u043e\u0434\u0443\u043b\u044f<\/strong><\/p>\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0434\u0432\u0443\u0445 \u043f\u0443\u043d\u043a\u0442\u0430\u0445 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0441\u044f \u0441\u043b\u0443\u0447\u0430\u0439, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0430 \u043d\u0430 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0442\u043e\u043c \u0436\u0435 \u043c\u043e\u0434\u0443\u043b\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f Store&lt;AppState>. \u041d\u043e \u044d\u0442\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0443\u0434\u043e\u0431\u043d\u043e. \u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u0442 Store, \u0442\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0443\u0434\u043e\u0431\u043d\u043e \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432 \u044d\u0442\u0438\u0445 \u043c\u043e\u0434\u0443\u043b\u044f\u0445. \u041d\u043e \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c Store&lt;AppState> \u0432 \u043c\u043e\u0434\u0443\u043b\u044c \u0446\u0435\u043b\u0438\u043a\u043e\u043c, \u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c. \u0413\u043b\u0430\u0432\u043d\u043e\u043c\u0443 \u043c\u043e\u0434\u0443\u043b\u044e \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043f\u0440\u043e FeatureModule, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043d\u0435\u043c\u0443. FeatureModule \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u043d\u0430\u0442\u044c \u043f\u0440\u043e AppModule, \u0442\u0430\u043a \u043a\u0430\u043a AppState \u043b\u0435\u0436\u0438\u0442 \u0432 AppModule:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/f6d\/a18\/f3d\/f6da18f3d6b9c01afeb649f774696675.jpg\" width=\"1920\" height=\"1080\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f6d\/a18\/f3d\/f6da18f3d6b9c01afeb649f774696675.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0440\u0435\u0448\u0430\u044e\u0442 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430\u0445:<\/p>\n<p><strong>ReSwift. <\/strong>\u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0438 \u043e\u0442 \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, select \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u043f\u043e\u043c\u043e\u0436\u0435\u0442. \u0412 FeatureModule \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c Store \u0441 \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u0442\u0438\u043f\u043e\u043c State, \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c select. \u0421\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0438 ReSwift \u043d\u0435 \u0434\u0430\u044e\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0439, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u0442\u0430\u043a\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438. \u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442 <strong>State Protocol and Where Clause <\/strong>\u0438\u0437 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u0443\u043d\u043a\u0442\u0430. \u0415\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u043a\u0440\u043e\u0435\u043c AppState \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u043c, \u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c Store&lt;AppState> \u0432 FeatureModule, \u043d\u0435 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u044f \u0441\u0430\u043c \u0442\u0438\u043f AppState.<\/p>\n<p><strong>TCA. <\/strong>\u0412 TCA \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 scope, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b\u0441\u044f \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u043f\u0443\u043d\u043a\u0442\u0435. \u041c\u0435\u0442\u043e\u0434 scope \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c Store, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043c\u043e\u0442\u0440\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0447\u0430\u0441\u0442\u044c \u0432\u0441\u0435\u0433\u043e State. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0437 Store&lt;AppState> \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c Store&lt;FeatureState> \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432 FeatureModule. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u0430 scope \u0438 \u0432\u0441\u0435\u0433\u043e Store \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 <a href=\"https:\/\/github.com\/pointfreeco\/swift-composable-architecture\/blob\/main\/Sources\/ComposableArchitecture\/Store.swift\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a>, \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0440\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u2014 <a href=\"https:\/\/www.pointfree.co\/episodes\/ep151-composable-architecture-performance-view-stores-and-scoping\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a>.<\/p>\n<p><strong>inDriver UDF. <\/strong>\u0412 \u0441\u0432\u043e\u0435\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0435 \u043c\u044b \u043f\u043e\u0448\u043b\u0438 \u043f\u043e \u043f\u0443\u0442\u0438 TCA \u0438 \u0440\u0430\u0437\u043b\u0438\u043d\u043e\u0432\u0430\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 scope. \u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c Combine \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c reducer \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u0434\u0435\u0442\u0430\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u043e\u0442 TCA, \u043d\u043e \u0438\u0434\u0435\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0430. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0445\u0435\u043c\u0443 \u0440\u0430\u0431\u043e\u0442\u044b: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/52d\/e5c\/30e\/52de5c30efd3a9102c3d8fbfcf6e8abf.jpg\" width=\"1920\" height=\"1080\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/52d\/e5c\/30e\/52de5c30efd3a9102c3d8fbfcf6e8abf.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<ol>\n<li>\n<p>Component \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 Action \u0432 LocalStore.<\/p>\n<\/li>\n<li>\n<p>LocalStore \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 Action, \u0430 \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u0443\u0435\u0442 \u0434\u0430\u043b\u044c\u0448\u0435 \u0432 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 Store.<\/p>\n<\/li>\n<li>\n<p>Reducer \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e Store \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 Action \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 AppState.<\/p>\n<\/li>\n<li>\n<p>LocalStore \u043f\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 AppState \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0438\u0437 \u043d\u0435\u0433\u043e LocalState.<\/p>\n<\/li>\n<li>\n<p>\u0412\u0441\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u0438 LocalStore \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 LocalStore.<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043d\u0430 4 \u0448\u0430\u0433\u0435 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0438 \u0441\u0442\u0430\u0440\u044b\u0439 LocalState. \u0415\u0441\u043b\u0438 \u043e\u043d \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0435 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u044f\u0442\u044c \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432 LocalStore \u043e\u0431 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445. \u042d\u0442\u043e \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0446\u0435\u043b\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 \u043e\u0442 \u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 Action \u0438\u0437 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u043d\u0435 \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u0438\u0445 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u0442\u0435\u0439\u0442.\u00a0<\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435. \u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u043b\u0438\u0448\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0447\u0430\u0441\u0442\u044f\u0445 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u0438 \u043a \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f Unidirectional Data Flow \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a <a href=\"https:\/\/github.com\/inDriver\/UDF\"><u>UDF<\/u><\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b\u00a0\u0440\u0435\u0448\u0438\u043b\u0438 <strong>\u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u043c<\/strong>. \u0412\u00a0\u043d\u0435\u043c \u0441\u043e\u0431\u0440\u0430\u043d\u044b \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u043b\u0438 \u043d\u0430\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0438 \u043c\u043d\u043e\u0433\u043e\u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442. \u041e\u043a\u043e\u043b\u043e \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430\u00a0UDF, \u0438\u00a0\u043c\u044b\u00a0\u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0430\u00a0\u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0425\u043e\u0447\u0443 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e UDF \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u0441\u0435\u0431\u044f \u043a\u0430\u043a \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430. \u0418\u00a0\u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u00a0\u0441\u0432\u043e\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 UDF \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u0435\u00a0\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0435 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438. \u041d\u0430\u00a0\u0441\u0432\u043e\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b\u00a0\u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0438, \u0447\u0442\u043e UDF-\u043f\u043e\u0434\u0445\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e, \u0438\u00a0\u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u00a0\u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/576660\/\"> https:\/\/habr.com\/ru\/articles\/576660\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/company\/indriver\/blog\/571394\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u044f\u00a0\u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043b \u043d\u0430\u0448\u0443 \u0433\u043b\u0430\u0432\u043d\u0443\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043f\u0440\u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 Unidirectional Data Flow (UDF)\u00a0\u2014 \u043c\u043e\u0434\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044e. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043d\u043e\u0433\u043e UDF-\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u043d\u0430\u00a0Swift, \u043d\u043e\u00a0\u043c\u0430\u043b\u043e \u043a\u0442\u043e \u0443\u0442\u043e\u0447\u043d\u044f\u0435\u0442, \u043a\u0430\u043a \u0438\u0445\u00a0\u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u00a0\u0431\u043e\u043b\u044c\u0448\u043e\u0435, \u043c\u043d\u043e\u0433\u043e\u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u0412\u043e\u00a0\u0432\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u044f\u00a0\u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f, \u0441\u00a0\u043a\u0430\u043a\u0438\u043c\u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043c\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0438\u00a0\u043a\u00a0\u043a\u0430\u043a\u0438\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u043c \u043f\u0440\u0438\u0448\u043b\u0438.<\/p>\n<p>\u0412\u00a0\u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c 3\u00a0\u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0438\u00a0\u0441\u0440\u0430\u0432\u043d\u0438\u043c, \u043a\u0430\u043a \u0440\u0430\u0437\u043d\u044b\u0435 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438 \u0438\u0445\u00a0\u0440\u0435\u0448\u0430\u044e\u0442. \u0414\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u044f\u00a0\u0432\u044b\u0431\u0440\u0430\u043b \u043e\u0434\u043d\u0438 \u0438\u0437\u00a0\u0441\u0430\u043c\u044b\u0445 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u2014 <a href=\"https:\/\/github.com\/ReSwift\/ReSwift\"><u>ReSwift<\/u><\/a> \u0438 <a href=\"https:\/\/github.com\/pointfreeco\/swift-composable-architecture\"><u>The Composable Architecture<\/u><\/a> (TCA). \u0412\u00a0\u043a\u043e\u043d\u0446\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043c\u044b\u00a0\u0432\u00a0\u0438\u0442\u043e\u0433\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438. \u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c!<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h2>3 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043c\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c <\/h2>\n<p><strong>1. \u0412\u0441\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0437\u043d\u0430\u044e\u0442 \u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/strong><\/p>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0435\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438\u00a0\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0432\u00a0\u043d\u0435\u043c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u043b\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u00a0\u0437\u0430\u043a\u0430\u0437\u0435. \u0423\u00a0\u044d\u0442\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0435\u0441\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043b\u0435\u0436\u0438\u0442 \u0432\u00a0AppState. \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0437\u043d\u0430\u0435\u0442 \u043e\u0431\u00a0AppState, \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u00a0\u043d\u0435\u0433\u043e \u0438\u00a0\u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430\u00a0\u044d\u043a\u0440\u0430\u043d:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0430\u043a\u0438\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0432\u00a0\u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0438\u00a0\u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437\u00a0\u043d\u0438\u0445 \u0437\u043d\u0430\u0435\u0442 \u043e\u0431\u00a0AppState. \u042d\u0442\u043e \u043f\u043b\u043e\u0445\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0430\u0440\u0443\u0448\u0430\u0435\u0442 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%97%D0%B0%D0%BA%D0%BE%D0%BD_%D0%94%D0%B5%D0%BC%D0%B5%D1%82%D1%80%D1%8B\"><u>\u0417\u0430\u043a\u043e\u043d \u0414\u0435\u043c\u0435\u0442\u0440\u044b<\/u><\/a>. \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u043d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 State, \u043d\u043e\u00a0\u0438\u043c\u00a0\u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0441\u043a\u0432\u043e\u0437\u044c AppState \u043a\u00a0\u0441\u0432\u043e\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u043c. \u0427\u0430\u0441\u0442\u043e \u0432\u00a0\u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u0435\u043c \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434:\u00a0 <\/p>\n<pre><code class=\"swift\">let state = appState.someInnerState.anotherInnerState.andAnotherOneState.finallyMyState<\/code><\/pre>\n<p>\u041f\u0438\u0441\u0430\u0442\u044c \u0438\u00a0\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u043a\u0440\u0430\u0439\u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e, \u0445\u043e\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0438\u00a0\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0421\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b\u00a0\u0437\u0430\u0445\u043e\u0442\u0438\u043c \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0432\u00a0\u0434\u0440\u0443\u0433\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0435\u0433\u043e \u0432\u00a0\u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0440\u0430\u0437\u0443 2 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b:<\/p>\n<ol>\n<li>\n<p>App1 \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043f\u0440\u043e Component, \u0447\u0442\u043e\u0431\u044b \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. Component \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043f\u0440\u043e App1, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a AppState. \u041c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438, \u0447\u0442\u043e \u043d\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u0449\u0438\u043a\u0443 Swift.<\/p>\n<\/li>\n<li>\n<p>Component \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043f\u0440\u043e App2, \u0430 \u0432 \u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u0435 \u0438 \u043e App3, App4 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.<\/p>\n<\/li>\n<\/ol>\n<p>\u0420\u0435\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043c\u043e\u0436\u043d\u043e, \u0437\u0430\u0431\u0440\u0430\u0432 State \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0432\u043d\u0443\u0442\u0440\u044c \u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0434\u0443\u043b\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043d\u0438\u00a0\u043e\u00a0\u043a\u043e\u043c \u043d\u0435\u00a0\u0437\u043d\u0430\u0435\u0442 \u0438\u00a0\u043d\u0435\u00a0\u0438\u043c\u0435\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439. \u0421\u0430\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0437\u043d\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u00a0\u0441\u0432\u043e\u0435\u043c \u0441\u0442\u0435\u0439\u0442\u0435. \u041c\u043e\u0434\u0443\u043b\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0437\u043d\u0430\u044e\u0442 \u043e\u00a0\u043c\u043e\u0434\u0443\u043b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u0438\u00a0AppState \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437\u00a0\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 State \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0438\u0437\u00a0\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f. \u041e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0443\u0447\u0438\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0441\u043b\u0443\u0448\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0443\u00a0\u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0435\u0439\u0442\u0430, \u0432\u00a0\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d\u00a0\u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043d. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u044d\u0442\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u0432\u00a0\u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430\u0445.<\/p>\n<p><strong>ReSwift<\/strong>. ReSwift \u0438\u0434\u0435\u0442 \u043f\u043e\u00a0\u043f\u0443\u0442\u0438 \u0441\u0432\u043e\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u0448\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0438\u043a\u0430 \u0438\u00a0\u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u0441\u0445\u043e\u0436\u0438\u0439\u00a0\u0441 <a href=\"https:\/\/redux.js.org\/usage\/deriving-data-selectors\"><u>c\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u0430\u043c\u0438 \u0438\u0437 Redux<\/u><\/a>. \u041f\u043e\u0434\u043f\u0438\u0441\u043a\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u0430 \u0431\u044b \u0442\u0430\u043a:<\/p>\n<pre><code class=\"swift\">store.subscribe(self) { $0.select { $0.componentState } }<\/code><\/pre>\n<p>\u0421\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u044b \u0432\u00a0Redux\u00a0\u2014 \u043c\u043e\u0449\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0441\u00a0\u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <a href=\"https:\/\/github.com\/reduxjs\/reselect\">reselect<\/a>. \u0412\u00a0ReSwift \u0442\u0430\u043a\u043e\u0439\u00a0\u0436\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0441\u043b\u0438 \u043f\u043e\u0441\u043b\u0435 \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438 Action \u0441\u0442\u0435\u0439\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043d\u0435\u00a0\u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f, \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043d\u0435\u00a0\u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0442\u043e\u0442\u00a0\u0436\u0435 \u0441\u0442\u0435\u0439\u0442 \u0435\u0449\u0435 \u0440\u0430\u0437.<\/p>\n<p><strong>TCA. <\/strong>\u0423\u00a0TCA \u0432\u00a0Store \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434 scope. \u041e\u043d\u00a0\u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0439 Store \u0441\u00a0\u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u044c\u044e \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438:<\/p>\n<pre><code class=\"swift\">let componentStore = store.scope(state: \\.componentState) \/\/ componentStore \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f Store&lt;ComponentState><\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430\u0448 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043d\u0430\u00a0componentStore. \u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043c\u044b\u00a0\u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0443 scope \u0432\u00a0\u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0442\u0440\u0435\u0442\u044c\u0435\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. TCA, \u043a\u0430\u043a \u0438\u00a0ReSwift, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0441\u0442\u0435\u0439\u0442\u044b, \u043d\u043e\u00a0\u0441\u00a0\u043f\u043e\u043c\u043e\u0449\u044c\u044e Combine\u00a0\u0438 <a href=\"https:\/\/developer.apple.com\/documentation\/combine\/fail\/removeduplicates()\"><u>removeduplicates()<\/u><\/a>.<\/p>\n<p><strong>inDriver UDF. <\/strong>\u041c\u044b\u00a0\u043f\u043e\u0448\u043b\u0438 \u043f\u043e\u00a0\u043f\u0440\u043e\u0441\u0442\u043e\u043c\u0443 \u043f\u0443\u0442\u0438 \u0438\u00a0\u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 KeyPath \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432\u00a0\u043c\u0435\u0442\u043e\u0434 connect:<\/p>\n<pre><code class=\"swift\">component.connect(to: store, state: \\.componentState)<\/code><\/pre>\n<p>\u041f\u043e\u043a\u0430 \u043c\u044b\u00a0\u043d\u0435\u00a0\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u043e\u0432 \u0441\u0442\u0435\u0439\u0442\u0430 (\u043e\u043d\u0430\u00a0\u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0432\u00a0\u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0442\u0440\u0435\u0442\u044c\u0435\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b). \u0417\u0430\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432\u00a0\u043c\u0435\u0442\u043e\u0434 connect \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043d\u0430\u00a0\u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u044b View-\u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043d\u0435\u00a0\u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c 2 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 View-\u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u043e\u0434\u0440\u044f\u0434. \u041f\u0440\u0430\u0432\u0434\u0430, \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c View-\u043c\u043e\u0434\u0435\u043b\u044c \u0435\u0449\u0435 \u0440\u0430\u0437.<\/p>\n<p><strong>2.<\/strong> <strong>2 \u043c\u043e\u0434\u0443\u043b\u044f \u0445\u043e\u0442\u044f\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u0444\u0438\u0447\u0443.<\/strong><\/p>\n<p><a class=\"anchor\" name=\"%D0%B4%D0%B2%D0%B0%20%D0%BC%D0%BE%D0%B4%D1%83%D0%BB%D1%8F\" id=\"\u0434\u0432\u0430 \u043c\u043e\u0434\u0443\u043b\u044f\">\u0434\u0443\u043b\u044f&#187;<\/a><\/p>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0435\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0444\u0438\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b\u00a0\u0445\u043e\u0442\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u00a02\u00a0\u043c\u043e\u0434\u0443\u043b\u044f\u0445. \u041e\u0431\u0430 \u043c\u043e\u0434\u0443\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432\u00a0\u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438. \u041b\u043e\u0433\u0438\u0447\u043d\u043e, \u0447\u0442\u043e \u0441\u0442\u0435\u0439\u0442 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437\u00a0\u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u0442\u0435\u0439\u0442 \u043f\u0440\u043e\u0444\u0438\u043b\u044f, \u0430\u00a0AppState \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u00a0\u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u0438\u00a0\u043f\u0440\u043e\u0444\u0438\u043b\u044f:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u00a0\u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b\u00a0\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043a\u043e\u043f\u0438\u0438 ProfileState \u0432\u00a03\u00a0\u043c\u0435\u0441\u0442\u0430\u0445: AppState, Feature1State \u0438\u00a0Feature2State. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u00a0\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043e\u0434\u0438\u043d, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u00a0ProfileState \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0432\u00a0\u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0435. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c Feature1 \u0438\u00a0Feature2 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u043c\u0435\u0442\u044c \u0432\u00a0\u0441\u0432\u043e\u0438\u0445 \u0441\u0442\u0435\u0439\u0442\u0430\u0445 ProfileState, \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a\u00a0AppState \u043e\u043d\u0438 \u043d\u0435\u00a0\u0438\u043c\u0435\u044e\u0442. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c 2\u00a0\u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b\u00a0\u0443\u0441\u043b\u043e\u0432\u043d\u043e \u043d\u0430\u0437\u0432\u0430\u043b\u0438 <strong>Computed Module State <\/strong>\u0438 <strong>State Protocol and Where Clause<\/strong>:<\/p>\n<p><strong>Computed Module State. <\/strong>\u0420\u0430\u0437\u0434\u0435\u043b\u0438\u043c FeatureState \u043d\u0430\u00a02\u00a0\u0447\u0430\u0441\u0442\u0438. \u041d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e FeatureState\u00a0\u2014 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u0439 \u0444\u0438\u0447\u0435. \u0418\u00a0FeatureModuleState\u00a0\u2014 FeatureState + \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0441\u0442\u0435\u0439\u0442\u044b:<\/p>\n<pre><code class=\"swift\">struct FeatureModuleState {     let feature: FeatureState     let profile: ProfileState }<\/code><\/pre>\n<p>\u0422\u043e\u0433\u0434\u0430 \u0432 AppState \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e FeatureState \u0438 ProfileState:<\/p>\n<pre><code class=\"swift\">struct AppState {     let feature1: Feature1State     let feature2: Feature2State     let profile: ProfileState }<\/code><\/pre>\n<p>ModuleState \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043a\u0430\u043a \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430:<\/p>\n<pre><code class=\"swift\">extension AppState {     var feature1Module: Feature1ModuleState {         .init(feature: feature1, profile: profile)     }   var feature2Module: Feature2ModuleState {     .init(feature: feature2, profile: profile) } }<\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u0430\u043a\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430\u00a0\u0443\u0440\u043e\u0432\u043d\u0435 AppState \u043c\u044b\u00a0\u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u043c, \u0447\u0442\u043e ProfileState \u0432\u00a0\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u00a0\u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0435. ModuleState\u00a0\u0436\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u0432\u043e\u0439 \u043f\u043e\u0434 \u043a\u0430\u0436\u0434\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c. \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043b\u0435\u0433\u043a\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0434 \u043b\u044e\u0431\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0444\u0438\u0447, \u043d\u043e\u00a0\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u043c\u043e\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043f\u043e\u0434 \u043a\u0430\u0436\u0434\u0443\u044e \u043d\u043e\u0432\u0443\u044e \u0444\u0438\u0447\u0443.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0435\u0441\u0442\u044c \u0432 \u0443\u0447\u0435\u0431\u043d\u044b\u0445 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430\u0445 TCA (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"https:\/\/github.com\/pointfreeco\/episode-code-samples\/blob\/main\/0073-modular-state-management-view-state\/PrimeTime\/PrimeTime\/ContentView.swift\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a>). \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 PrimeModelState \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u043c\u044b\u043c \u0438 \u043d\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 AppState.<\/p>\n<p><strong>State Protocol and Where Clause. <\/strong>\u0412\u043c\u0435\u0441\u0442\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u043c\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u044b. \u041e\u0431\u044a\u044f\u0432\u0438\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b Feature1ModuleState \u0438\u00a0\u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0435\u0433\u043e \u0432\u00a0AppState:<\/p>\n<pre><code class=\"swift\">protocol Feature1ModuleState {     let feature: Feature1State     let protifle: ProfileState } extension AppState: Feature1ModuleState {}<\/code><\/pre>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0434\u043b\u044f Feature2. \u0422\u0435\u043f\u0435\u0440\u044c \u0444\u0438\u0447\u0438 \u043c\u043e\u0433\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0443\u00a0\u0441\u0435\u0431\u044f FeatureModuleState \u0438\u00a0\u043d\u0435\u00a0\u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e AppState \u0438\u0445\u00a0\u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442. \u041d\u043e\u00a0\u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u00a0\u2014 \u0432\u00a0Swift <a href=\"https:\/\/forums.swift.org\/t\/covariance-contravariance\/39635\"><u>\u043a\u043e\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u044c<\/u><\/a> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c Store&lt;AppState> \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a Store&lt;FeatureModuleState>. \u0417\u0430\u0442\u043e \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u0434\u0430\u0442\u044c FeatureModuleState \u043a\u0430\u043a \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430:<\/p>\n<pre><code class=\"swift\">class FeatureViewController&lt;S: StoreType>: UIViewController where S.State: FeatureModuleState { let store: S init(store: S) {   self.store = store super.init(nibName: nil, bundle: nil)   } } <\/code><\/pre>\n<p>\u0418\u0437 \u043f\u043b\u044e\u0441\u043e\u0432 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0432\u044b\u0434\u0435\u043b\u0438\u043c \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u043c\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u0445, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b. \u041c\u0438\u043d\u0443\u0441 \u2014 \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u043a Generic \u043d\u0430 Store \u0441 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435\u043c, \u0447\u0442\u043e \u0435\u0433\u043e State \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 FeatureModuleState. \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0438 \u043c\u043e\u0434\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0438 <a href=\"https:\/\/github.com\/ReSwift\/ReSwift\/issues\/377#issuecomment-434364649\"><u>ReSwift<\/u><\/a>.<\/p>\n<p>\u0414\u043b\u044f \u0441\u0435\u0431\u044f \u043c\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 <strong>Computed Module State <\/strong>\u043a\u0430\u043a \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0438 \u043d\u0435 \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e\u0449\u0435\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/p>\n<p><strong>3.<\/strong> <strong>\u041f\u043e\u0434\u043f\u0438\u0441\u043a\u0430 \u043d\u0430 Store \u0432\u043d\u0443\u0442\u0440\u0438 \u043c\u043e\u0434\u0443\u043b\u044f<\/strong><\/p>\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0434\u0432\u0443\u0445 \u043f\u0443\u043d\u043a\u0442\u0430\u0445 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0441\u044f \u0441\u043b\u0443\u0447\u0430\u0439, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0430 \u043d\u0430 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0442\u043e\u043c \u0436\u0435 \u043c\u043e\u0434\u0443\u043b\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f Store&lt;AppState>. \u041d\u043e \u044d\u0442\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0443\u0434\u043e\u0431\u043d\u043e. \u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u0442 Store, \u0442\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0443\u0434\u043e\u0431\u043d\u043e \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432 \u044d\u0442\u0438\u0445 \u043c\u043e\u0434\u0443\u043b\u044f\u0445. \u041d\u043e \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c Store&lt;AppState> \u0432 \u043c\u043e\u0434\u0443\u043b\u044c \u0446\u0435\u043b\u0438\u043a\u043e\u043c, \u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c. \u0413\u043b\u0430\u0432\u043d\u043e\u043c\u0443 \u043c\u043e\u0434\u0443\u043b\u044e \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043f\u0440\u043e FeatureModule, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043d\u0435\u043c\u0443. FeatureModule \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u043d\u0430\u0442\u044c \u043f\u0440\u043e AppModule, \u0442\u0430\u043a \u043a\u0430\u043a AppState \u043b\u0435\u0436\u0438\u0442 \u0432 AppModule:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0440\u0435\u0448\u0430\u044e\u0442 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430\u0445:<\/p>\n<p><strong>ReSwift. <\/strong>\u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0438 \u043e\u0442 \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, select \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u043f\u043e\u043c\u043e\u0436\u0435\u0442. \u0412 FeatureModule \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c Store \u0441 \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u0442\u0438\u043f\u043e\u043c State, \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c select. \u0421\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0438 ReSwift \u043d\u0435 \u0434\u0430\u044e\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0439, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u0442\u0430\u043a\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438. \u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442 <strong>State Protocol and Where Clause <\/strong>\u0438\u0437 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u0443\u043d\u043a\u0442\u0430. \u0415\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u043a\u0440\u043e\u0435\u043c AppState \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u043c, \u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c Store&lt;AppState> \u0432 FeatureModule, \u043d\u0435 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u044f \u0441\u0430\u043c \u0442\u0438\u043f AppState.<\/p>\n<p><strong>TCA. <\/strong>\u0412 TCA \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 scope, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b\u0441\u044f \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u043f\u0443\u043d\u043a\u0442\u0435. \u041c\u0435\u0442\u043e\u0434 scope \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c Store, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043c\u043e\u0442\u0440\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0447\u0430\u0441\u0442\u044c \u0432\u0441\u0435\u0433\u043e State. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0437 Store&lt;AppState> \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c Store&lt;FeatureState> \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432 FeatureModule. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u0430 scope \u0438 \u0432\u0441\u0435\u0433\u043e Store \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 <a href=\"https:\/\/github.com\/pointfreeco\/swift-composable-architecture\/blob\/main\/Sources\/ComposableArchitecture\/Store.swift\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a>, \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0440\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u2014 <a href=\"https:\/\/www.pointfree.co\/episodes\/ep151-composable-architecture-performance-view-stores-and-scoping\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a>.<\/p>\n<p><strong>inDriver UDF. <\/strong>\u0412 \u0441\u0432\u043e\u0435\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0435 \u043c\u044b \u043f\u043e\u0448\u043b\u0438 \u043f\u043e \u043f\u0443\u0442\u0438 TCA \u0438 \u0440\u0430\u0437\u043b\u0438\u043d\u043e\u0432\u0430\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 scope. \u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c Combine \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c reducer \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u0434\u0435\u0442\u0430\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u043e\u0442 TCA, \u043d\u043e \u0438\u0434\u0435\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0430. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0445\u0435\u043c\u0443 \u0440\u0430\u0431\u043e\u0442\u044b: <\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<ol>\n<li>\n<p>Component \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 Action \u0432 LocalStore.<\/p>\n<\/li>\n<li>\n<p>LocalStore \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 Action, \u0430 \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u0443\u0435\u0442 \u0434\u0430\u043b\u044c\u0448\u0435 \u0432 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 Store.<\/p>\n<\/li>\n<li>\n<p>Reducer \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e Store \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 Action \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 AppState.<\/p>\n<\/li>\n<li>\n<p>LocalStore \u043f\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 AppState \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0438\u0437 \u043d\u0435\u0433\u043e LocalState.<\/p>\n<\/li>\n<li>\n<p>\u0412\u0441\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u0438 LocalStore \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 LocalStore.<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043d\u0430 4 \u0448\u0430\u0433\u0435 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0438 \u0441\u0442\u0430\u0440\u044b\u0439 LocalState. \u0415\u0441\u043b\u0438 \u043e\u043d \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0435 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u044f\u0442\u044c \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432 LocalStore \u043e\u0431 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445. \u042d\u0442\u043e \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0446\u0435\u043b\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 \u043e\u0442 \u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 Action \u0438\u0437 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u043d\u0435 \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u0438\u0445 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u0442\u0435\u0439\u0442.\u00a0<\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435. \u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u043b\u0438\u0448\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0447\u0430\u0441\u0442\u044f\u0445 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u0438 \u043a \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f Unidirectional Data Flow \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a <a href=\"https:\/\/github.com\/inDriver\/UDF\"><u>UDF<\/u><\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b\u00a0\u0440\u0435\u0448\u0438\u043b\u0438 <strong>\u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u043c<\/strong>. \u0412\u00a0\u043d\u0435\u043c \u0441\u043e\u0431\u0440\u0430\u043d\u044b \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u043b\u0438 \u043d\u0430\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0438 \u043c\u043d\u043e\u0433\u043e\u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442. \u041e\u043a\u043e\u043b\u043e \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430\u00a0UDF, \u0438\u00a0\u043c\u044b\u00a0\u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0430\u00a0\u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0425\u043e\u0447\u0443 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e UDF \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u0441\u0435\u0431\u044f \u043a\u0430\u043a \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430. \u0418\u00a0\u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u00a0\u0441\u0432\u043e\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 UDF \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-399580","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/399580","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=399580"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/399580\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=399580"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=399580"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=399580"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}