Warning: preg_grep(): Compilation failed: quantifier does not follow a repeatable item at offset 213 in /var/www/tg-me/post.php on line 75
Библиотека мобильного разработчика | Android, iOS, Swift, Retrofit, Moshi, Chuck | Telegram Webview: mobileproglib/5826 -
Telegram Group & Telegram Channel
📱 How to: оптимизировать работу с API в мобильных приложениях

Проблема: Долгая загрузка данных, лишние запросы и падение приложения при плохом интернете.

1️⃣ Кеширование данных

Используйте Room (Android) или CoreData (iOS) для локального хранения:

// Android + Kotlin  
@Dao
interface UserDao {
@Query("SELECT * FROM users")
fun getUsers(): Flow<List<User>>
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun saveUsers(users: List<User>)
}

// iOS + Swift  
func saveUsers(_ users: [User]) {
let context = persistentContainer.viewContext
users.forEach { user in
let entity = UserEntity(context: context)
entity.id = user.id
entity.name = user.name
}
try? context.save()
}


2️⃣ Пагинация

Делите данные на страницы:

🔵 Android: Paging 3 + RemoteMediator
🔵 iOS: UICollectionViewDiffableDataSource + async/await

3️⃣ Повтор запросов при ошибках

// iOS  
func fetchWithRetry(maxAttempts: Int = 3) async throws -> Data {
for attempt in 1...maxAttempts {
do {
return try await fetchData()
} catch {
if attempt == maxAttempts { throw error }
try await Task.sleep(nanoseconds: 1_000_000_000 * UInt64(attempt))
}
}
fatalError("Unreachable")
}


4️⃣ Оптимизация JSON

🔵 Используйте kotlinx.serialization (Android) и Codable (iOS)
🔵 Исключайте ненужные поля через @Transient / @Ignore

5️⃣ HTTP-кеширование

// Android + OkHttp  
val client = OkHttpClient.Builder()
.cache(Cache(cacheDir, 10 * 1024 * 1024)) // 10 MB
.build()


💬 Как вы оптимизируете работу в своих проектах? Делитесь опытом

🐸 Библиотека мобильного разработчика

#буст
Please open Telegram to view this post
VIEW IN TELEGRAM



tg-me.com/mobileproglib/5826
Create:
Last Update:

📱 How to: оптимизировать работу с API в мобильных приложениях

Проблема: Долгая загрузка данных, лишние запросы и падение приложения при плохом интернете.

1️⃣ Кеширование данных

Используйте Room (Android) или CoreData (iOS) для локального хранения:

// Android + Kotlin  
@Dao
interface UserDao {
@Query("SELECT * FROM users")
fun getUsers(): Flow<List<User>>
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun saveUsers(users: List<User>)
}

// iOS + Swift  
func saveUsers(_ users: [User]) {
let context = persistentContainer.viewContext
users.forEach { user in
let entity = UserEntity(context: context)
entity.id = user.id
entity.name = user.name
}
try? context.save()
}


2️⃣ Пагинация

Делите данные на страницы:

🔵 Android: Paging 3 + RemoteMediator
🔵 iOS: UICollectionViewDiffableDataSource + async/await

3️⃣ Повтор запросов при ошибках

// iOS  
func fetchWithRetry(maxAttempts: Int = 3) async throws -> Data {
for attempt in 1...maxAttempts {
do {
return try await fetchData()
} catch {
if attempt == maxAttempts { throw error }
try await Task.sleep(nanoseconds: 1_000_000_000 * UInt64(attempt))
}
}
fatalError("Unreachable")
}


4️⃣ Оптимизация JSON

🔵 Используйте kotlinx.serialization (Android) и Codable (iOS)
🔵 Исключайте ненужные поля через @Transient / @Ignore

5️⃣ HTTP-кеширование

// Android + OkHttp  
val client = OkHttpClient.Builder()
.cache(Cache(cacheDir, 10 * 1024 * 1024)) // 10 MB
.build()


💬 Как вы оптимизируете работу в своих проектах? Делитесь опытом

🐸 Библиотека мобильного разработчика

#буст

BY Библиотека мобильного разработчика | Android, iOS, Swift, Retrofit, Moshi, Chuck




Share with your friend now:
tg-me.com/mobileproglib/5826

View MORE
Open in Telegram


Библиотека мобильного разработчика | Android iOS Swift Retrofit Moshi Chuck Telegram | DID YOU KNOW?

Date: |

Telegram Auto-Delete Messages in Any Chat

Some messages aren’t supposed to last forever. There are some Telegram groups and conversations where it’s best if messages are automatically deleted in a day or a week. Here’s how to auto-delete messages in any Telegram chat. You can enable the auto-delete feature on a per-chat basis. It works for both one-on-one conversations and group chats. Previously, you needed to use the Secret Chat feature to automatically delete messages after a set time. At the time of writing, you can choose to automatically delete messages after a day or a week. Telegram starts the timer once they are sent, not after they are read. This won’t affect the messages that were sent before enabling the feature.

At a time when the Indian stock market is peaking and has rallied immensely compared to global markets, there are companies that have not performed in the last 10 years. These are definitely a minor portion of the market considering there are hundreds of stocks that have turned multibagger since 2020. What went wrong with these stocks? Reasons vary from corporate governance, sectoral weakness, company specific and so on. But the more important question is, are these stocks worth buying?

Библиотека мобильного разработчика | Android iOS Swift Retrofit Moshi Chuck from us


Telegram Библиотека мобильного разработчика | Android, iOS, Swift, Retrofit, Moshi, Chuck
FROM USA