Telegram Group & Telegram Channel
💎 Разработка приложения на SwiftUI: Почему нужен DI впервую очередь

SwiftUI по умолчанию делает многое автоматически — это удобно, но без DI ты быстро начнёшь жёстко связывать View, ViewModel, сервисы, хранилище, API и т.д.

А значит тестировать, переиспользовать, изменять, рефакторить код — страшно и больно

С DI легко заменяешь зависимости на моки:

let mock = MockUserService()
let vm = ProfileViewModel(userService: mock)


Чистое разделение ответственности c помощью DI помогает разделить на компоненты:
View — Отображение
ViewModel — Логика UI
Service — Данные/API

Гибкость для разных окружений:


#if DEBUG
let service = MockUserService()
#else
let service = RealUserService()
#endif


Лёгкий переход к модульной архитектуре

С DI ты можешь:
- выносить модули в отдельные фреймворки,
- управлять зависимостями централизованно,
- добавлять фичи, не ломая всё остальное.

В следущем посте разберем в чем главное отличие работы с DI в SwiftUI и UIKit
Please open Telegram to view this post
VIEW IN TELEGRAM



group-telegram.com/iosmakesmehate/2983
Create:
Last Update:

💎 Разработка приложения на SwiftUI: Почему нужен DI впервую очередь

SwiftUI по умолчанию делает многое автоматически — это удобно, но без DI ты быстро начнёшь жёстко связывать View, ViewModel, сервисы, хранилище, API и т.д.

А значит тестировать, переиспользовать, изменять, рефакторить код — страшно и больно

С DI легко заменяешь зависимости на моки:


let mock = MockUserService()
let vm = ProfileViewModel(userService: mock)


Чистое разделение ответственности c помощью DI помогает разделить на компоненты:
View — Отображение
ViewModel — Логика UI
Service — Данные/API

Гибкость для разных окружений:


#if DEBUG
let service = MockUserService()
#else
let service = RealUserService()
#endif


Лёгкий переход к модульной архитектуре

С DI ты можешь:
- выносить модули в отдельные фреймворки,
- управлять зависимостями централизованно,
- добавлять фичи, не ломая всё остальное.

В следущем посте разберем в чем главное отличие работы с DI в SwiftUI и UIKit

BY iOS Makes Me Hate






Share with your friend now:
group-telegram.com/iosmakesmehate/2983

View MORE
Open in Telegram


Telegram | DID YOU KNOW?

Date: |

In this regard, Sebi collaborated with the Telecom Regulatory Authority of India (TRAI) to reduce the vulnerability of the securities market to manipulation through misuse of mass communication medium like bulk SMS. What distinguishes the app from competitors is its use of what's known as channels: Public or private feeds of photos and videos that can be set up by one person or an organization. The channels have become popular with on-the-ground journalists, aid workers and Ukrainian President Volodymyr Zelenskyy, who broadcasts on a Telegram channel. The channels can be followed by an unlimited number of people. Unlike Facebook, Twitter and other popular social networks, there is no advertising on Telegram and the flow of information is not driven by an algorithm. In addition, Telegram's architecture limits the ability to slow the spread of false information: the lack of a central public feed, and the fact that comments are easily disabled in channels, reduce the space for public pushback. "We're seeing really dramatic moves, and it's all really tied to Ukraine right now, and in a secondary way, in terms of interest rates," Octavio Marenzi, CEO of Opimas, told Yahoo Finance Live on Thursday. "This war in Ukraine is going to give the Fed the ammunition, the cover that it needs, to not raise interest rates too quickly. And I think Jay Powell is a very tepid sort of inflation fighter and he's not going to do as much as he needs to do to get that under control. And this seems like an excuse to kick the can further down the road still and not do too much too soon." "And that set off kind of a battle royale for control of the platform that Durov eventually lost," said Nathalie Maréchal of the Washington advocacy group Ranking Digital Rights.
from us


Telegram iOS Makes Me Hate
FROM American