0Pricing
Jetpack Compose Academy · Ders

Kapsamlar ve Bileşen Ömürleri

Bağımlılıkların ne kadar süre yaşayacağını denetleyin.

Kapsamlar ve Bileşen Ömürleri, CoddyKit'te ücretsiz bir Jetpack Compose Academy dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Jetpack Compose Academy öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Jetpack Compose Academy kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

What a Scope Controls

A scope decides how long Hilt keeps a single instance alive and where it gets shared. It is about lifetime, not just creation.

Unscoped by Default

Without a scope annotation, Hilt builds a new instance every time it is requested. That is fine for cheap, stateless objects.

@Provides
fun provideMapper(): Mapper = Mapper() // fresh each time

Components Mirror Android

Hilt provides a set of components that match Android lifetimes, from the whole app down to a single view. Each owns its own instances.

App-Wide With Singleton

SingletonComponent lives as long as the app. Bindings here with @Singleton are created once and shared across every screen.

@InstallIn(SingletonComponent::class)

Per-Activity Lifetime

ActivityComponent follows one Activity. Use @ActivityScoped to share an instance across that Activity and recreate it on a new one.

@ActivityScoped
class FormState @Inject constructor()

ViewModel Scope

ViewModelComponent matches a ViewModel's life. With @ViewModelScoped a dependency is shared only within that one ViewModel.

@ViewModelScoped
class SessionCache @Inject constructor()

Scope Equals Annotation Plus Component

Each scope annotation pairs with one component. @Singleton goes with SingletonComponent, @ActivityScoped with ActivityComponent, and so on.

Lifetimes Form a Hierarchy

Components nest: an Activity lives inside the app, a Fragment inside the Activity. A child can use anything its parents provide.

Scope With Care

Scoping costs memory, because the instance is held until its component dies. Only scope objects whose state genuinely needs to be shared.

Avoid Leaking the Wider Scope

Never inject a short-lived object, like an Activity, into a Singleton. The longer-lived holder would keep it alive and leak memory. ⚠️

Picking the Right Scope

Match the scope to the data's life: app config in Singleton, screen state in ViewModelScoped. The right fit prevents leaks and waste.

Quick Check

You want one shared instance for the entire app lifetime. Which scope fits?

Recap: Lifetimes Under Control

You learned that scopes tie an instance's lifetime to a component, from Singleton down to ViewModel, so dependencies live exactly as long as needed. 🎯

Sıkça Sorulan Sorular

“Kapsamlar ve Bileşen Ömürleri” dersi ücretsiz mi?

Evet — “Kapsamlar ve Bileşen Ömürleri” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Jetpack Compose Academy kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Jetpack Compose Academy kursu toplamda 4 dersten oluşur.

“Kapsamlar ve Bileşen Ömürleri” dersinde ne öğreneceğim?

Bağımlılıkların ne kadar süre yaşayacağını denetleyin. Jetpack Compose Academy ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

Jetpack Compose Academy öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te Jetpack Compose Academy, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.

“Kapsamlar ve Bileşen Ömürleri” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu Jetpack Compose Academy dersinde kod yazıp çalıştırabilir miyim?

Evet. Her Jetpack Compose Academy dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. DI Neden Kullanılır: Test Edilebilir, Ayrıştırılmış Kod
  2. Modüller, @Provides ve @Binds
  3. hiltViewModel ve @HiltViewModel
  4. Kapsamlar ve Bileşen Ömürleri
← Jetpack Compose Academy Sayfasına Dön