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: |

The regulator said it had received information that messages containing stock tips and other investment advice with respect to selected listed companies are being widely circulated through websites and social media platforms such as Telegram, Facebook, WhatsApp and Instagram. You may recall that, back when Facebook started changing WhatsApp’s terms of service, a number of news outlets reported on, and even recommended, switching to Telegram. Pavel Durov even said that users should delete WhatsApp “unless you are cool with all of your photos and messages becoming public one day.” But Telegram can’t be described as a more-secure version of WhatsApp. Although some channels have been removed, the curation process is considered opaque and insufficient by analysts. At the start of 2018, the company attempted to launch an Initial Coin Offering (ICO) which would enable it to enable payments (and earn the cash that comes from doing so). The initial signals were promising, especially given Telegram’s user base is already fairly crypto-savvy. It raised an initial tranche of cash – worth more than a billion dollars – to help develop the coin before opening sales to the public. Unfortunately, third-party sales of coins bought in those initial fundraising rounds raised the ire of the SEC, which brought the hammer down on the whole operation. In 2020, officials ordered Telegram to pay a fine of $18.5 million and hand back much of the cash that it had raised. DFR Lab sent the image through Microsoft Azure's Face Verification program and found that it was "highly unlikely" that the person in the second photo was the same as the first woman. The fact-checker Logically AI also found the claim to be false. The woman, Olena Kurilo, was also captured in a video after the airstrike and shown to have the injuries.
from sg


Telegram iOS Makes Me Hate
FROM American