{"id":323465,"date":"2021-05-20T15:00:31","date_gmt":"2021-05-20T15:00:31","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=323465"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=323465","title":{"rendered":"\u041f\u0440\u0438\u043c\u0435\u0440 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0433\u043e \u0430\u043d\u0434\u0440\u043e\u0438\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Navigation component \u0438 Koin (DI)"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043f\u0440\u0438\u0432\u0435\u0442!<\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0433\u043e \u0430\u043d\u0434\u0440\u043e\u0438\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e NavComponent (JetPack) \u0438 Koin (DI).<\/p>\n<p>\u0423 \u043d\u0430\u0441 \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u0430\u043d\u0434\u0440\u043e\u0438\u0434 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0438\u0447\u0438 (Feature) \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430 &#8212; \u044d\u0442\u043e \u043d\u0435\u043a\u0430\u044f \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0430. \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0444\u0438\u0447\u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u043c\u0438 \u0438 \u0433\u0438\u0431\u043a\u0438\u043c\u0438.<\/p>\n<p>\u0422\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u0444\u0438\u0447\u0430\u043c \u043c\u043e\u0436\u043d\u043e \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a:<\/p>\n<ol>\n<li>\n<p>\u0424\u0438\u0447\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0434\u043c\u0435\u043d\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0438 UI \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0438\u0447\u0438 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u0435\u0451 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 (\u043c\u0435\u0442\u043a\u0443) \u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432\u0445\u043e\u0434\u0430\/\u0432\u044b\u0445\u043e\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0430\u043c\u0430 \u0444\u0438\u0447\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u0444\u0438\u0447.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 feature on-off \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>\u0414\u043b\u044f \u043c\u0435\u043d\u044f feature &#8212; \u044d\u0442\u043e \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f, \u043f\u043e\u043a\u0443\u043f\u043a\u0430. \u0424\u0438\u0447\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0432\u043e\u0439 UI \u0433\u0440\u0430\u0444 (\u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043e\u0432), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0432 backStack \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438, \u0430 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u0444\u0438\u0447\u0438, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0442\u043e\u0447\u043a\u0443 \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0438\u0447\u0438.<\/p>\n<p>\u0423\u0441\u043b\u043e\u0432\u043d\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u0437 \u0434\u0432\u0443\u0445 \u0444\u0438\u0447:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ca3\/2e0\/e83\/ca32e0e83c83a23a9ce9e85327f9b204.jpg\" width=\"470\" height=\"277\"><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430 \u0441\u0445\u0435\u043c\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0435\u0441\u0442\u044c MainFragment (M) \u0438 \u0434\u0432\u0435 \u0444\u0438\u0447\u0438 (\u0410 \u0438 \u0412). \u0418\u0437 \u041c \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 \u0444\u0438\u0447\u0438 \u0410 \u0438 \u0412. \u0410 \u0438\u0437 \u0444\u0438\u0447\u0438 \u0412 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0432 \u0444\u0438\u0447\u0443 \u0410. \u041f\u0440\u0438\u0447\u0435\u043c, \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0444\u0438\u0447\u0438 \u0410 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u0432 \u0442\u043e\u0447\u043a\u0443 \u0432\u044b\u0437\u043e\u0432\u0430: \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u043f\u0430\u043b\u0438 \u0432 \u0444\u0438\u0447\u0443 \u0410 \u0438\u0437 M, \u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u0432 \u041c, \u0430 \u0435\u0441\u043b\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u043b\u0438 \u0444\u0438\u0447\u0443 \u0410 \u0438\u0437 \u0412, \u0442\u043e \u0432 \u0412. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u0442\u0435\u043a \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c\u0441\u044f. \u04101, \u04102, B1, B2 &#8212; \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u0444\u0438\u0447.<\/p>\n<p>\u041a\u0430\u0436\u0434\u0430\u044f \u0444\u0438\u0447\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0442\u0440\u0435\u0445 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0430\u043d\u0434\u0440\u043e\u0438\u0434 \u043f\u0440\u043e\u0435\u043a\u0442\u0430: API, BL, UI.  <\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/35e\/fa4\/75e\/35efa475eac2845a3d20b1154333e509.jpg\" width=\"418\" height=\"311\"><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 \u0441\u0442\u0440\u0435\u043b\u043a\u0430 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.&nbsp; A -&gt; B &#8212; \u043c\u043e\u0434\u0443\u043b\u044c \u0410 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0412.<\/p>\n<ul>\n<li>\n<p>API \u043c\u043e\u0434\u0443\u043b\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0444\u0438\u0447\u0438, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043c\u043e\u0433\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432\u0441\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u0438. <strong>Lint \u043f\u0440\u0430\u0432\u0438\u043b\u043e: \u041d\u0430 API \u043c\u043e\u0434\u0443\u043b\u044c \u043c\u043e\u0433\u0443\u0442 \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043b\u044e\u0431\u044b\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u0438.<\/strong><\/p>\n<\/li>\n<li>\n<p>BL \u043c\u043e\u0434\u0443\u043b\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443 \u0444\u0438\u0447\u0438. \u041c\u043e\u0434\u0443\u043b\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 API \u0444\u0438\u0447\u0438. \u041c\u043e\u0434\u0443\u043b\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 internal \u043a\u043b\u0430\u0441\u0441\u044b &#8212; \u0437\u0430\u043a\u0440\u044b\u0442 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u043a\u0440\u043e\u043c\u0435 DI \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. <strong>Lint \u043f\u0440\u0430\u0432\u0438\u043b\u043e: \u041d\u0430 BL \u043c\u043e\u0434\u0443\u043b\u044c \u043c\u043e\u0436\u0435\u0442&nbsp; \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e APP \u043c\u043e\u0434\u0443\u043b\u044c.<\/strong><\/p>\n<\/li>\n<li>\n<p>UI \u043c\u043e\u0434\u0443\u043b\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0444\u0438\u0447\u0438. \u041c\u043e\u0434\u0443\u043b\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 internal \u043a\u043b\u0430\u0441\u0441\u044b &#8212; \u0437\u0430\u043a\u0440\u044b\u0442 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u043a\u0440\u043e\u043c\u0435 DI \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 NavGraph, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0433\u0440\u0430\u0444 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043a\u0430\u043a nested graph. <strong>Lint \u043f\u0440\u0430\u0432\u0438\u043b\u043e: \u041d\u0430 UI \u043c\u043e\u0434\u0443\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e APP \u043c\u043e\u0434\u0443\u043b\u044c.<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u0410 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<ul>\n<li>\n<p>\u041c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u0430\u0448\u0438 \u0444\u0438\u0447\u0438 \u043c\u043e\u0434\u0443\u043b\u0438<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (app)<\/p>\n<\/li>\n<li>\n<p>\u0412 app \u043c\u043e\u0434\u0443\u043b\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u043d\u0430\u0448 \u043f\u0430\u0437\u0437\u043b \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0438\u0437 DI \u043c\u043e\u0434\u0443\u043b\u0435\u0439<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"kotlin\">startKoin {             modules(                 listOf(                     AppKoinModule.create(),                                      FeatureAImplKoinModule.create(),                     FeatureAUiKoinModule.create(),                     FeatureBImplKoinModule.create(),                     FeatureBUiKoinModule.create()                 )             )         }<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0444\u0438\u0447\u0438, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043a app \u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u0447\u043a\u0443 \u0432 DI, \u0438 \u044d\u0442\u0430 \u043b\u043e\u0433\u0438\u043a\u0430 \u0441\u0440\u0430\u0437\u0443 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e, \u043d\u0435 \u0432\u0430\u0436\u043d\u043e \u043a\u0442\u043e \u0438 \u0433\u0434\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0444\u0438\u0447\u0443. C UI \u043c\u043e\u0434\u0443\u043b\u0435\u043c \u0435\u0441\u0442\u044c \u043d\u044e\u0430\u043d\u0441 &#8212; \u044d\u0442\u043e \u0433\u0440\u0430\u0444, \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 root \u0433\u0440\u0430\u0444 app \u043c\u043e\u0434\u0443\u043b\u044f.<\/p>\n<ul>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0433\u0440\u0430\u0444\u044b \u043d\u0430\u0448\u0438\u0445 \u0444\u0438\u0447 \u0432 root \u0433\u0440\u0430\u0444 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (app). \u041f\u043e\u043a\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0433\u0440\u0430\u0444\u0430, \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u043d\u0430\u0434 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439, \u0442\u0430\u043c \u043d\u0435\u043c\u0430\u043b\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c.<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0437\u043e\u0432 \u0444\u0438\u0447\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"kotlin\">&nbsp;appNavigator.navigateTo(FeatureADestination::class.java)<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 (\u043f\u043e \u0441\u0443\u0442\u0438 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u0435\u0442\u043a\u0430)<\/p>\n<pre><code class=\"kotlin\">interface FeatureADestination : ModuleNavInfo<\/code><\/pre>\n<p>\u0410 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 ModuleNavInfo \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0443\u0436\u0435 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043a\u0430\u043a \u0444\u0438\u0447\u0443 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f FeatureADestination \u0441\u043f\u0440\u044f\u0442\u0430\u043d\u0430 \u0432 UI \u043c\u043e\u0434\u0443\u043b\u0435.<\/p>\n<pre><code class=\"kotlin\">interface ModuleNavInfo {     fun getNavigationStartPointResId(): Int      fun isFeatureAvailable(): Boolean }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0435\u0441\u0442\u044c navigator, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u0441\u0442\u0430\u0435\u0442 \u043d\u0443\u0436\u043d\u044b\u0435 \u0444\u0438\u0447\u0438 \u043f\u043e \u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u043c \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u0445\u043e\u0434. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430\u0432\u0438\u0433\u0430\u0442\u043e\u0440\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043b\u0438\u0448\u044c \u0432\u044b\u0442\u0430\u0449\u0438\u0442\u044c \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0432 DI \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e ModuleNavInfo:<\/p>\n<pre><code class=\"kotlin\">class KoinAppNavigator : AppNavigator {      private val navigationDestinationInternal = MutableLiveEvent&lt;EventArgs&lt;ModuleNavInfo&gt;&gt;()     override val navigationDestination =         navigationDestinationInternal as LiveData&lt;EventArgs&lt;ModuleNavInfo&gt;&gt;      private val navigationIntDestinationInternal = MutableLiveEvent&lt;EventArgs&lt;Int&gt;&gt;()     override val navigationResDestination: LiveData&lt;EventArgs&lt;Int&gt;&gt;         get() = navigationIntDestinationInternal      override fun &lt;T : ModuleNavInfo&gt; navigateTo(         moduleNavInfo: Class&lt;T&gt;     ) {         val destination = KoinJavaComponent.get(moduleNavInfo) as ModuleNavInfo         navigationDestinationInternal.postValue(EventArgs(destination))     }      override fun navigateTo(destination: Int) {         navigationIntDestinationInternal.postValue(EventArgs(destination))     }      override fun &lt;T : ModuleNavInfo&gt; resolveModule(moduleNavInfo: Class&lt;T&gt;): ModuleNavInfo? {         return try {             KoinJavaComponent.get(moduleNavInfo)         } catch (e: Exception) {             null         }     }      override fun &lt;T : ModuleNavInfo&gt; isCanNavigateTo(moduleNavInfo: Class&lt;T&gt;): Boolean {         return resolveModule(moduleNavInfo) != null     } } <\/code><\/pre>\n<p>ModuleNavInfo \u0438 AppNavigator \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c, \u0437\u0434\u0435\u0441\u044c \u044f \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u0430\u043c \u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u0421\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0447\u0435\u0440\u0435\u0437 ModuleNavInfo. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0444\u0438\u0447\u0438, \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c StateFlow \u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0435\u0433\u043e. \u0412\u0441\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u043e \u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435. \u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043f\u0440\u044f\u0442\u0430\u0442\u044c \u043e\u0442 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u043c\u0438\u0440\u0430 \u0432 BL \u043c\u043e\u0434\u0443\u043b\u044f\u0445.<\/p>\n<p>\u041a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430 <a href=\"https:\/\/github.com\/ar2code\/modularization_example\" rel=\"noopener noreferrer nofollow\"><u>\u0433\u0438\u0442\u0445\u0430\u0431<\/u><\/a>.<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p>\n<\/div>\n<p> \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\/post\/558494\/\"> https:\/\/habr.com\/ru\/post\/558494\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043f\u0440\u0438\u0432\u0435\u0442!<\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0433\u043e \u0430\u043d\u0434\u0440\u043e\u0438\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e NavComponent (JetPack) \u0438 Koin (DI).<\/p>\n<p>\u0423 \u043d\u0430\u0441 \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u0430\u043d\u0434\u0440\u043e\u0438\u0434 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0438\u0447\u0438 (Feature) \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430 &#8212; \u044d\u0442\u043e \u043d\u0435\u043a\u0430\u044f \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0430. \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0444\u0438\u0447\u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u043c\u0438 \u0438 \u0433\u0438\u0431\u043a\u0438\u043c\u0438.<\/p>\n<p>\u0422\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u0444\u0438\u0447\u0430\u043c \u043c\u043e\u0436\u043d\u043e \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a:<\/p>\n<ol>\n<li>\n<p>\u0424\u0438\u0447\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0434\u043c\u0435\u043d\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0438 UI \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0438\u0447\u0438 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u0435\u0451 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 (\u043c\u0435\u0442\u043a\u0443) \u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432\u0445\u043e\u0434\u0430\/\u0432\u044b\u0445\u043e\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0430\u043c\u0430 \u0444\u0438\u0447\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u0444\u0438\u0447.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 feature on-off \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>\u0414\u043b\u044f \u043c\u0435\u043d\u044f feature &#8212; \u044d\u0442\u043e \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f, \u043f\u043e\u043a\u0443\u043f\u043a\u0430. \u0424\u0438\u0447\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0432\u043e\u0439 UI \u0433\u0440\u0430\u0444 (\u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043e\u0432), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0432 backStack \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438, \u0430 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u0444\u0438\u0447\u0438, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0442\u043e\u0447\u043a\u0443 \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0438\u0447\u0438.<\/p>\n<p>\u0423\u0441\u043b\u043e\u0432\u043d\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u0437 \u0434\u0432\u0443\u0445 \u0444\u0438\u0447:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430 \u0441\u0445\u0435\u043c\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0435\u0441\u0442\u044c MainFragment (M) \u0438 \u0434\u0432\u0435 \u0444\u0438\u0447\u0438 (\u0410 \u0438 \u0412). \u0418\u0437 \u041c \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 \u0444\u0438\u0447\u0438 \u0410 \u0438 \u0412. \u0410 \u0438\u0437 \u0444\u0438\u0447\u0438 \u0412 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0432 \u0444\u0438\u0447\u0443 \u0410. \u041f\u0440\u0438\u0447\u0435\u043c, \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0444\u0438\u0447\u0438 \u0410 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u0432 \u0442\u043e\u0447\u043a\u0443 \u0432\u044b\u0437\u043e\u0432\u0430: \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u043f\u0430\u043b\u0438 \u0432 \u0444\u0438\u0447\u0443 \u0410 \u0438\u0437 M, \u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u0432 \u041c, \u0430 \u0435\u0441\u043b\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u043b\u0438 \u0444\u0438\u0447\u0443 \u0410 \u0438\u0437 \u0412, \u0442\u043e \u0432 \u0412. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u0442\u0435\u043a \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c\u0441\u044f. \u04101, \u04102, B1, B2 &#8212; \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u0444\u0438\u0447.<\/p>\n<p>\u041a\u0430\u0436\u0434\u0430\u044f \u0444\u0438\u0447\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0442\u0440\u0435\u0445 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0430\u043d\u0434\u0440\u043e\u0438\u0434 \u043f\u0440\u043e\u0435\u043a\u0442\u0430: API, BL, UI.  <\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 \u0441\u0442\u0440\u0435\u043b\u043a\u0430 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.&nbsp; A -&gt; B &#8212; \u043c\u043e\u0434\u0443\u043b\u044c \u0410 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0412.<\/p>\n<ul>\n<li>\n<p>API \u043c\u043e\u0434\u0443\u043b\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0444\u0438\u0447\u0438, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043c\u043e\u0433\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432\u0441\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u0438. <strong>Lint \u043f\u0440\u0430\u0432\u0438\u043b\u043e: \u041d\u0430 API \u043c\u043e\u0434\u0443\u043b\u044c \u043c\u043e\u0433\u0443\u0442 \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043b\u044e\u0431\u044b\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u0438.<\/strong><\/p>\n<\/li>\n<li>\n<p>BL \u043c\u043e\u0434\u0443\u043b\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443 \u0444\u0438\u0447\u0438. \u041c\u043e\u0434\u0443\u043b\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 API \u0444\u0438\u0447\u0438. \u041c\u043e\u0434\u0443\u043b\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 internal \u043a\u043b\u0430\u0441\u0441\u044b &#8212; \u0437\u0430\u043a\u0440\u044b\u0442 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u043a\u0440\u043e\u043c\u0435 DI \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. <strong>Lint \u043f\u0440\u0430\u0432\u0438\u043b\u043e: \u041d\u0430 BL \u043c\u043e\u0434\u0443\u043b\u044c \u043c\u043e\u0436\u0435\u0442&nbsp; \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e APP \u043c\u043e\u0434\u0443\u043b\u044c.<\/strong><\/p>\n<\/li>\n<li>\n<p>UI \u043c\u043e\u0434\u0443\u043b\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0444\u0438\u0447\u0438. \u041c\u043e\u0434\u0443\u043b\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 internal \u043a\u043b\u0430\u0441\u0441\u044b &#8212; \u0437\u0430\u043a\u0440\u044b\u0442 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u043a\u0440\u043e\u043c\u0435 DI \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 NavGraph, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0433\u0440\u0430\u0444 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043a\u0430\u043a nested graph. <strong>Lint \u043f\u0440\u0430\u0432\u0438\u043b\u043e: \u041d\u0430 UI \u043c\u043e\u0434\u0443\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e APP \u043c\u043e\u0434\u0443\u043b\u044c.<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u0410 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<ul>\n<li>\n<p>\u041c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u0430\u0448\u0438 \u0444\u0438\u0447\u0438 \u043c\u043e\u0434\u0443\u043b\u0438<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (app)<\/p>\n<\/li>\n<li>\n<p>\u0412 app \u043c\u043e\u0434\u0443\u043b\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u043d\u0430\u0448 \u043f\u0430\u0437\u0437\u043b \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0438\u0437 DI \u043c\u043e\u0434\u0443\u043b\u0435\u0439<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"kotlin\">startKoin {             modules(                 listOf(                     AppKoinModule.create(),                                      FeatureAImplKoinModule.create(),                     FeatureAUiKoinModule.create(),                     FeatureBImplKoinModule.create(),                     FeatureBUiKoinModule.create()                 )             )         }<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0444\u0438\u0447\u0438, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043a app \u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u0447\u043a\u0443 \u0432 DI, \u0438 \u044d\u0442\u0430 \u043b\u043e\u0433\u0438\u043a\u0430 \u0441\u0440\u0430\u0437\u0443 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e, \u043d\u0435 \u0432\u0430\u0436\u043d\u043e \u043a\u0442\u043e \u0438 \u0433\u0434\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0444\u0438\u0447\u0443. C UI \u043c\u043e\u0434\u0443\u043b\u0435\u043c \u0435\u0441\u0442\u044c \u043d\u044e\u0430\u043d\u0441 &#8212; \u044d\u0442\u043e \u0433\u0440\u0430\u0444, \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 root \u0433\u0440\u0430\u0444 app \u043c\u043e\u0434\u0443\u043b\u044f.<\/p>\n<ul>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0433\u0440\u0430\u0444\u044b \u043d\u0430\u0448\u0438\u0445 \u0444\u0438\u0447 \u0432 root \u0433\u0440\u0430\u0444 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (app). \u041f\u043e\u043a\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0433\u0440\u0430\u0444\u0430, \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u043d\u0430\u0434 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439, \u0442\u0430\u043c \u043d\u0435\u043c\u0430\u043b\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c.<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0437\u043e\u0432 \u0444\u0438\u0447\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"kotlin\">&nbsp;appNavigator.navigateTo(FeatureADestination::class.java)<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 (\u043f\u043e \u0441\u0443\u0442\u0438 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u0435\u0442\u043a\u0430)<\/p>\n<pre><code class=\"kotlin\">interface FeatureADestination : ModuleNavInfo<\/code><\/pre>\n<p>\u0410 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 ModuleNavInfo \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0443\u0436\u0435 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043a\u0430\u043a \u0444\u0438\u0447\u0443 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f FeatureADestination \u0441\u043f\u0440\u044f\u0442\u0430\u043d\u0430 \u0432 UI \u043c\u043e\u0434\u0443\u043b\u0435.<\/p>\n<pre><code class=\"kotlin\">interface ModuleNavInfo {     fun getNavigationStartPointResId(): Int      fun isFeatureAvailable(): Boolean }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0435\u0441\u0442\u044c navigator, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u0441\u0442\u0430\u0435\u0442 \u043d\u0443\u0436\u043d\u044b\u0435 \u0444\u0438\u0447\u0438 \u043f\u043e \u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u043c \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u0445\u043e\u0434. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430\u0432\u0438\u0433\u0430\u0442\u043e\u0440\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043b\u0438\u0448\u044c \u0432\u044b\u0442\u0430\u0449\u0438\u0442\u044c \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0432 DI \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e ModuleNavInfo:<\/p>\n<pre><code class=\"kotlin\">class KoinAppNavigator : AppNavigator {      private val navigationDestinationInternal = MutableLiveEvent&lt;EventArgs&lt;ModuleNavInfo&gt;&gt;()     override val navigationDestination =         navigationDestinationInternal as LiveData&lt;EventArgs&lt;ModuleNavInfo&gt;&gt;      private val navigationIntDestinationInternal = MutableLiveEvent&lt;EventArgs&lt;Int&gt;&gt;()     override val navigationResDestination: LiveData&lt;EventArgs&lt;Int&gt;&gt;         get() = navigationIntDestinationInternal      override fun &lt;T : ModuleNavInfo&gt; navigateTo(         moduleNavInfo: Class&lt;T&gt;     ) {         val destination = KoinJavaComponent.get(moduleNavInfo) as ModuleNavInfo         navigationDestinationInternal.postValue(EventArgs(destination))     }      override fun navigateTo(destination: Int) {         navigationIntDestinationInternal.postValue(EventArgs(destination))     }      override fun &lt;T : ModuleNavInfo&gt; resolveModule(moduleNavInfo: Class&lt;T&gt;): ModuleNavInfo? {         return try {             KoinJavaComponent.get(moduleNavInfo)         } catch (e: Exception) {             null         }     }      override fun &lt;T : ModuleNavInfo&gt; isCanNavigateTo(moduleNavInfo: Class&lt;T&gt;): Boolean {         return resolveModule(moduleNavInfo) != null     } } <\/code><\/pre>\n<p>ModuleNavInfo \u0438 AppNavigator \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c, \u0437\u0434\u0435\u0441\u044c \u044f \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u0430\u043c \u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u0421\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0447\u0435\u0440\u0435\u0437 ModuleNavInfo. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0444\u0438\u0447\u0438, \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c StateFlow \u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0435\u0433\u043e. \u0412\u0441\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u043e \u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435. \u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043f\u0440\u044f\u0442\u0430\u0442\u044c \u043e\u0442 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u043c\u0438\u0440\u0430 \u0432 BL \u043c\u043e\u0434\u0443\u043b\u044f\u0445.<\/p>\n<p>\u041a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430 <a href=\"https:\/\/github.com\/ar2code\/modularization_example\" rel=\"noopener noreferrer nofollow\"><u>\u0433\u0438\u0442\u0445\u0430\u0431<\/u><\/a>.<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p>\n<\/div>\n<p> \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\/post\/558494\/\"> https:\/\/habr.com\/ru\/post\/558494\/<\/a><br \/><\/br><\/br><\/p>\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-323465","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/323465","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=323465"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/323465\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=323465"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=323465"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=323465"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}