Share
Embed
Transcript
165 slides
-
AbemaTV, Inc. All Rights Reserved AbemaTV, Inc. All Rights Reserved
1 AndroidΞϓϦͰɺ ҆ఆͯ͠ಈ࡞ͤ͞ ܧଓతʹ։ൃ͢ΔͨΊʹɺ ઃܭͷݪଇΛར༻ͯ͠ɺ ։ൃͨ͠ 2023 March 16th גࣜձࣾαΠόʔΤʔδΣϯτ takahirom(@new_runnable) -
AbemaTV, Inc. All Rights Reserved ࣗݾհ 2 ໟडਸ༸ (ΊΜ͡Ύ͔ͨͻΖ ͱಡΈ·͢)
takahiromͱ͍͏໊લͰΑ͘Qiitaॻ͍ͨΓOSS ࡞ͬͨΓ͍ͯ͠·͢ɻ ABEMAɺAndroidΤϯδχΞ CyberAgent Developer Expert Google Developers Expert for Android DroidKaigi Co-Organizer, App Leader -
AbemaTV, Inc. All Rights Reserved ࠓճհ͢Δ࣮Λಋೖͨ͠ը໘ 3 ػೳ • ์ૹͷࢹௌ
• ͔͚ͬ࠶ੜͷࢹௌ • ݟಀ͠৴ࢹௌ • ϚϧνΞϯάϧ • ίϝϯτ • ͳͲ FIFA ϫʔϧυΧοϓ Χλʔϧ 2022 ޙɺ ܧଓͯ͠ར༻͍ͯ͘͠ը໘ FIFA ϫʔϧυΧοϓ Χλʔϧ 2022 ʹ͚ͯ৽ن Ͱ࡞ͨ͠ը໘ ABEMAͰFIFA ϫʔϧυΧοϓΛࢹௌ͢Δํ๏ʁϚϧνΞϯάϧɺݟಀ͠৴ɺ͔͚ͬ࠶ੜͳͲศརͳػೳΛ͝հ https://times.abema.tv/fifaworldcup/articles/-/10036755 “ABEMAͰϫʔϧυΧοϓ2022Λࢹௌ͢Δํ๏ʂྉ͍ۚ͘ΒʁըͰ͖Δʁ”ΑΓ https://times.abema.tv/fifaworldcup/articles/-/10048409 -
AbemaTV, Inc. All Rights Reserved ࠓճͷ“ઃܭͷݪଇ”ͱ 4 AndroidͷެࣜαΠτʹ AndroidͷΞϓϦͷઃܭΨΠυ͕͋Γɺ
ͦͷதʹ͍͔ͭ͘ݪଇ͕ࡌ͍ͬͯͯɺ ͦΕΛࢀߟʹ͠ͳ͕Β ABEMAͰͲ͏࡞ͬͨͷ͔Λઆ໌͍͖ͯ͠· ͢ɻ ͯ͢ͷΞϓϦͰ͑ΔͷͰͳ͘ɺ վળ͕·ͩ·ͩ͋Δͱࢥ͏ͷͰɺ ͜͏͍͏Γํ͋Δͷ͔ͱ͍͏͙Β͍Ͱײ͡ Ͱݟ͍͚ͯͨͩΔͱΑ͍͔͠Ε·ͤΜɻ Android DevelopersͷGuide to app architectureͳͲʹ ܝࡌ͞Ε͍ͯΔͷ Guide to app architecture https://developer.android.com/topic/architecture -
AbemaTV, Inc. All Rights Reserved ϝϦοτ Android Developersʹ͋Δઃܭ֓೦Λ ࢀর Single
Source of Truth(SSoT)ͱ 6 https://developer.android.com/topic/architecture#single-source-of-truth -
AbemaTV, Inc. All Rights Reserved ϝϦοτ Android Developersʹ͋Δઃܭ֓೦Λ ࢀর Single
Source of Truth(SSoT)ͱ 6 • Guide to app architectureͷCommon architectural principlesͷҰͭ https://developer.android.com/topic/architecture#single-source-of-truth -
AbemaTV, Inc. All Rights Reserved ϝϦοτ Android Developersʹ͋Δઃܭ֓೦Λ ࢀর Single
Source of Truth(SSoT)ͱ 6 • Guide to app architectureͷCommon architectural principlesͷҰͭ • ϙΠϯτ https://developer.android.com/topic/architecture#single-source-of-truth -
AbemaTV, Inc. All Rights Reserved ϝϦοτ Android Developersʹ͋Δઃܭ֓೦Λ ࢀর Single
Source of Truth(SSoT)ͱ 6 • Guide to app architectureͷCommon architectural principlesͷҰͭ • ϙΠϯτ ◦ SSoTσʔλͷΦʔφʔ https://developer.android.com/topic/architecture#single-source-of-truth -
AbemaTV, Inc. All Rights Reserved ϝϦοτ Android Developersʹ͋Δઃܭ֓೦Λ ࢀর Single
Source of Truth(SSoT)ͱ 6 • Guide to app architectureͷCommon architectural principlesͷҰͭ • ϙΠϯτ ◦ SSoTσʔλͷΦʔφʔ ◦ SSoT͚͕ͩσʔλΛมߋͰ͖Δ https://developer.android.com/topic/architecture#single-source-of-truth -
AbemaTV, Inc. All Rights Reserved ϝϦοτ Android Developersʹ͋Δઃܭ֓೦Λ ࢀর Single
Source of Truth(SSoT)ͱ 6 • Guide to app architectureͷCommon architectural principlesͷҰͭ • ϙΠϯτ ◦ SSoTσʔλͷΦʔφʔ ◦ SSoT͚͕ͩσʔλΛมߋͰ͖Δ ◦ SSoTImmutableͳσʔλΛެ։͢Δ https://developer.android.com/topic/architecture#single-source-of-truth -
AbemaTV, Inc. All Rights Reserved ϝϦοτ Android Developersʹ͋Δઃܭ֓೦Λ ࢀর Single
Source of Truth(SSoT)ͱ 6 • Guide to app architectureͷCommon architectural principlesͷҰͭ • ϙΠϯτ ◦ SSoTσʔλͷΦʔφʔ ◦ SSoT͚͕ͩσʔλΛมߋͰ͖Δ ◦ SSoTImmutableͳσʔλΛެ։͢Δ ◦ SSoT֎͔ΒσʔλΛมߋՄೳͳ͔ؔ ΠϕϯτΛड͚औΔ https://developer.android.com/topic/architecture#single-source-of-truth -
AbemaTV, Inc. All Rights Reserved ϝϦοτ Android Developersʹ͋Δઃܭ֓೦Λ ࢀর Single
Source of Truth(SSoT)ͱ 6 • Guide to app architectureͷCommon architectural principlesͷҰͭ • ϙΠϯτ ◦ SSoTσʔλͷΦʔφʔ ◦ SSoT͚͕ͩσʔλΛมߋͰ͖Δ ◦ SSoTImmutableͳσʔλΛެ։͢Δ ◦ SSoT֎͔ΒσʔλΛมߋՄೳͳ͔ؔ ΠϕϯτΛड͚औΔ • σʔλͷूதཧ https://developer.android.com/topic/architecture#single-source-of-truth -
AbemaTV, Inc. All Rights Reserved ϝϦοτ Android Developersʹ͋Δઃܭ֓೦Λ ࢀর Single
Source of Truth(SSoT)ͱ 6 • Guide to app architectureͷCommon architectural principlesͷҰͭ • ϙΠϯτ ◦ SSoTσʔλͷΦʔφʔ ◦ SSoT͚͕ͩσʔλΛมߋͰ͖Δ ◦ SSoTImmutableͳσʔλΛެ։͢Δ ◦ SSoT֎͔ΒσʔλΛมߋՄೳͳ͔ؔ ΠϕϯτΛड͚औΔ • σʔλͷूதཧ • ଞͷͱ͜Ζ͔Βσʔλ͕มߋ͞Εͳ ͍Α͏ʹอޢ͢Δ https://developer.android.com/topic/architecture#single-source-of-truth -
AbemaTV, Inc. All Rights Reserved ϝϦοτ Android Developersʹ͋Δઃܭ֓೦Λ ࢀর Single
Source of Truth(SSoT)ͱ 6 • Guide to app architectureͷCommon architectural principlesͷҰͭ • ϙΠϯτ ◦ SSoTσʔλͷΦʔφʔ ◦ SSoT͚͕ͩσʔλΛมߋͰ͖Δ ◦ SSoTImmutableͳσʔλΛެ։͢Δ ◦ SSoT֎͔ΒσʔλΛมߋՄೳͳ͔ؔ ΠϕϯτΛड͚औΔ • σʔλͷूதཧ • ଞͷͱ͜Ζ͔Βσʔλ͕มߋ͞Εͳ ͍Α͏ʹอޢ͢Δ • σʔλͷมߋ͕ՄೳʹͳΔ https://developer.android.com/topic/architecture#single-source-of-truth -
AbemaTV, Inc. All Rights Reserved ͱͱͷ࣮ͷ1 Single Source of Truth(SSoT)ΛͲ͏͔ͬͨ
7 fun playIfNeeded() { if(!isResumed) return if(!player.isPlaying()) return if(!viewModel.isAuthorized()) { // Ͳ͔͜Ͱ·ͨplayIfNeededΛ // ݺͿඞཁ͕͋Δ requestAuthorize() return } if(!viewModel.isUserPaused()) { return } player.play() } ΠϕϯτϕʔεͰಈ͘ίʔυͷྫ -
AbemaTV, Inc. All Rights Reserved ͱͱͷ࣮ͷ1 Single Source of Truth(SSoT)ΛͲ͏͔ͬͨ
7 • ΠϕϯτϕʔεͰίʔυ͕ಈ͘Α͏ʹͳ͍ͬͯͯSSoT͕ͳ͔ͬͨ fun playIfNeeded() { if(!isResumed) return if(!player.isPlaying()) return if(!viewModel.isAuthorized()) { // Ͳ͔͜Ͱ·ͨplayIfNeededΛ // ݺͿඞཁ͕͋Δ requestAuthorize() return } if(!viewModel.isUserPaused()) { return } player.play() } ΠϕϯτϕʔεͰಈ͘ίʔυͷྫ -
AbemaTV, Inc. All Rights Reserved ͱͱͷ࣮ͷ1 Single Source of Truth(SSoT)ΛͲ͏͔ͬͨ
7 • ΠϕϯτϕʔεͰίʔυ͕ಈ͘Α͏ʹͳ͍ͬͯͯSSoT͕ͳ͔ͬͨ ◦ ྫ͑ɺplayIfNeeded()ΛݺΜͩΒதͰ࠶ੜՄೳ͔Λఆͯ͠࠶ ੜ͢ΔͳͲɻ fun playIfNeeded() { if(!isResumed) return if(!player.isPlaying()) return if(!viewModel.isAuthorized()) { // Ͳ͔͜Ͱ·ͨplayIfNeededΛ // ݺͿඞཁ͕͋Δ requestAuthorize() return } if(!viewModel.isUserPaused()) { return } player.play() } ΠϕϯτϕʔεͰಈ͘ίʔυͷྫ -
AbemaTV, Inc. All Rights Reserved ͱͱͷ࣮ͷ1 Single Source of Truth(SSoT)ΛͲ͏͔ͬͨ
7 • ΠϕϯτϕʔεͰίʔυ͕ಈ͘Α͏ʹͳ͍ͬͯͯSSoT͕ͳ͔ͬͨ ◦ ྫ͑ɺplayIfNeeded()ΛݺΜͩΒதͰ࠶ੜՄೳ͔Λఆͯ͠࠶ ੜ͢ΔͳͲɻ ◦ దͳλΠϛϯάͰ͜ΕΛݺͳ͍ͱ࠶ੜ͞Εͳ͔ͬͨΓ͢ Δɻ fun playIfNeeded() { if(!isResumed) return if(!player.isPlaying()) return if(!viewModel.isAuthorized()) { // Ͳ͔͜Ͱ·ͨplayIfNeededΛ // ݺͿඞཁ͕͋Δ requestAuthorize() return } if(!viewModel.isUserPaused()) { return } player.play() } ΠϕϯτϕʔεͰಈ͘ίʔυͷྫ -
AbemaTV, Inc. All Rights Reserved ͱͱͷ࣮ͷ1 Single Source of Truth(SSoT)ΛͲ͏͔ͬͨ
7 • ΠϕϯτϕʔεͰίʔυ͕ಈ͘Α͏ʹͳ͍ͬͯͯSSoT͕ͳ͔ͬͨ ◦ ྫ͑ɺplayIfNeeded()ΛݺΜͩΒதͰ࠶ੜՄೳ͔Λఆͯ͠࠶ ੜ͢ΔͳͲɻ ◦ దͳλΠϛϯάͰ͜ΕΛݺͳ͍ͱ࠶ੜ͞Εͳ͔ͬͨΓ͢ Δɻ ◦ ϓϨΠϠʔͷঢ়ଶͷSSoTͲ͜ͳͷ͔ෆ໌ͩͬͨɻViewʁ PlayerʁViewModelʁ fun playIfNeeded() { if(!isResumed) return if(!player.isPlaying()) return if(!viewModel.isAuthorized()) { // Ͳ͔͜Ͱ·ͨplayIfNeededΛ // ݺͿඞཁ͕͋Δ requestAuthorize() return } if(!viewModel.isUserPaused()) { return } player.play() } ΠϕϯτϕʔεͰಈ͘ίʔυͷྫ -
AbemaTV, Inc. All Rights Reserved ͱͱͷ࣮ͷ2 Single Source of Truth(SSoT)ΛͲ͏͔ͬͨ
8 ViewModelͰ߹ੑΛऔΔͷ͕͍͠ྫ class ViewModel { val shouldPlay = MutableStateFlow(false) val authorized = MutableStateFlow(false) val isResumed = MutableStateFlow(false) private fun authorized() { authorized.value = true if (isResumed.value) { shouldPlay.value = true } } fun onResume() { isResumed.value = true if (authorized.value) { shouldPlay.value = true } } } ※UI states: single stream or multiple streams? https://developer.android.com/topic/architecture/ui-layer -
AbemaTV, Inc. All Rights Reserved ͱͱͷ࣮ͷ2 Single Source of Truth(SSoT)ΛͲ͏͔ͬͨ
8 • ߹ੑ ViewModelͰ߹ੑΛऔΔͷ͕͍͠ྫ class ViewModel { val shouldPlay = MutableStateFlow(false) val authorized = MutableStateFlow(false) val isResumed = MutableStateFlow(false) private fun authorized() { authorized.value = true if (isResumed.value) { shouldPlay.value = true } } fun onResume() { isResumed.value = true if (authorized.value) { shouldPlay.value = true } } } ※UI states: single stream or multiple streams? https://developer.android.com/topic/architecture/ui-layer -
AbemaTV, Inc. All Rights Reserved ͱͱͷ࣮ͷ2 Single Source of Truth(SSoT)ΛͲ͏͔ͬͨ
8 • ߹ੑ ◦ ViewModelͷ͍ΖΜͳ͔ؔΒ͍Ζ͍Ζͳঢ়ଶΛ ͍͡ΔͷͰ߹ੑΛऔΔͷ͕͔ͬͨ͠ɻ ViewModelͰ߹ੑΛऔΔͷ͕͍͠ྫ class ViewModel { val shouldPlay = MutableStateFlow(false) val authorized = MutableStateFlow(false) val isResumed = MutableStateFlow(false) private fun authorized() { authorized.value = true if (isResumed.value) { shouldPlay.value = true } } fun onResume() { isResumed.value = true if (authorized.value) { shouldPlay.value = true } } } ※UI states: single stream or multiple streams? https://developer.android.com/topic/architecture/ui-layer -
AbemaTV, Inc. All Rights Reserved ͱͱͷ࣮ͷ2 Single Source of Truth(SSoT)ΛͲ͏͔ͬͨ
8 • ߹ੑ ◦ ViewModelͷ͍ΖΜͳ͔ؔΒ͍Ζ͍Ζͳঢ়ଶΛ ͍͡ΔͷͰ߹ੑΛऔΔͷ͕͔ͬͨ͠ɻ ◦ ύϑΥʔϚϯεͳͲͷӨڹ͕͋·Γͳͦ͞͏ͳͱ ͜ΖͰɺؔ࿈͋Δͷʹؔͯ͠߹ੑͷ؍͔ ΒUiModelͰ͖Δ͚ͩҰ͕͍͍ͭ (※) ViewModelͰ߹ੑΛऔΔͷ͕͍͠ྫ class ViewModel { val shouldPlay = MutableStateFlow(false) val authorized = MutableStateFlow(false) val isResumed = MutableStateFlow(false) private fun authorized() { authorized.value = true if (isResumed.value) { shouldPlay.value = true } } fun onResume() { isResumed.value = true if (authorized.value) { shouldPlay.value = true } } } ※UI states: single stream or multiple streams? https://developer.android.com/topic/architecture/ui-layer -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ Single Source of Truth(SSoT)ΛͲ͏͔ͬͨ
9 • buildUiModel(stateFlow1, stateFlow2, block: (T1, T2) -> R): StateFlow<R> ͱ͍͏ ؔΛఆٛͨ͠ɻ -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ Single Source of Truth(SSoT)ΛͲ͏͔ͬͨ
9 • buildUiModel(stateFlow1, stateFlow2, block: (T1, T2) -> R): StateFlow<R> ͱ͍͏ ؔΛఆٛͨ͠ɻ ◦ StateFlowΛ࡞Δؔɻ -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ Single Source of Truth(SSoT)ΛͲ͏͔ͬͨ
9 • buildUiModel(stateFlow1, stateFlow2, block: (T1, T2) -> R): StateFlow<R> ͱ͍͏ ؔΛఆٛͨ͠ɻ ◦ StateFlowΛ࡞Δؔɻ ◦ ViewModelͷதͰ͏ɻ -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ Single Source of Truth(SSoT)ΛͲ͏͔ͬͨ
9 • buildUiModel(stateFlow1, stateFlow2, block: (T1, T2) -> R): StateFlow<R> ͱ͍͏ ؔΛఆٛͨ͠ɻ ◦ StateFlowΛ࡞Δؔɻ ◦ ViewModelͷதͰ͏ɻ ◦ தجຊతʹFlowͷcombine()͕ͩɺॳظΛଞͷStateFlow͔ΒblockΛݺͼ ग़ͯ͠ɺܭࢉ͢ΔॴΛҰͭʹͰ͖ΔΑ͏ʹͨ͠ɻ -
AbemaTV, Inc. All Rights Reserved buildUiModel()ͷఆٛ Single Source of Truth(SSoT)ΛͲ͏͔ͬͨ
10 fun <T1, T2, T3, R> ViewModel.buildUiModel( flow: StateFlow<T1>, flow2: StateFlow<T2>, flow3: StateFlow<T3>, transform: (T1, T2, T3) -> R, ): StateFlow<R> = combine( flow = flow, flow2 = flow2, flow3 = flow3, transform = transform ).stateIn( scope = viewModelScope, started = SharingStarted.WhileSubscribed(5_000), initialValue = transform( flow.value, flow2.value, flow3.value ) ) -
AbemaTV, Inc. All Rights Reserved buildUiModel()ͷఆٛ Single Source of Truth(SSoT)ΛͲ͏͔ͬͨ
10 fun <T1, T2, T3, R> ViewModel.buildUiModel( flow: StateFlow<T1>, flow2: StateFlow<T2>, flow3: StateFlow<T3>, transform: (T1, T2, T3) -> R, ): StateFlow<R> = combine( flow = flow, flow2 = flow2, flow3 = flow3, transform = transform ).stateIn( scope = viewModelScope, started = SharingStarted.WhileSubscribed(5_000), initialValue = transform( flow.value, flow2.value, flow3.value ) ) ͜͜ͰॳظΛܭࢉͯ͠͠·͏ Ҿ͕ͯ͢StateFlowͳͷͰɺ͜Ε ͕ՄೳʹͳΔɻ -
AbemaTV, Inc. All Rights Reserved private val productPlaybackStateFlow: StateFlow<ProductPlaybackState> =
buildUiModel( isScreenVisibleStateFlow, isUserPausedStateFlow, isAuthorizedStateFlow ) { screenVisible, userPaused, authorized -> if(!authorized) { ProductPlaybackState.ShouldStop }else if (userPaused || !screenVisible) { ProductPlaybackState.ShouldPause } else { ProductPlaybackState.ShouldPlay } } ྫ Single Source of Truth(SSoT)ΛͲ͏͔ͬͨ 11 -
AbemaTV, Inc. All Rights Reserved private val productPlaybackStateFlow: StateFlow<ProductPlaybackState> =
buildUiModel( isScreenVisibleStateFlow, isUserPausedStateFlow, isAuthorizedStateFlow ) { screenVisible, userPaused, authorized -> if(!authorized) { ProductPlaybackState.ShouldStop }else if (userPaused || !screenVisible) { ProductPlaybackState.ShouldPause } else { ProductPlaybackState.ShouldPlay } } ྫ Single Source of Truth(SSoT)ΛͲ͏͔ͬͨ 11 immutableͳσʔλΛ ࣋ͭStateFlow -
AbemaTV, Inc. All Rights Reserved private val productPlaybackStateFlow: StateFlow<ProductPlaybackState> =
buildUiModel( isScreenVisibleStateFlow, isUserPausedStateFlow, isAuthorizedStateFlow ) { screenVisible, userPaused, authorized -> if(!authorized) { ProductPlaybackState.ShouldStop }else if (userPaused || !screenVisible) { ProductPlaybackState.ShouldPause } else { ProductPlaybackState.ShouldPlay } } ྫ Single Source of Truth(SSoT)ΛͲ͏͔ͬͨ 11 buildUiModel() immutableͳσʔλΛ ࣋ͭStateFlow -
AbemaTV, Inc. All Rights Reserved private val productPlaybackStateFlow: StateFlow<ProductPlaybackState> =
buildUiModel( isScreenVisibleStateFlow, isUserPausedStateFlow, isAuthorizedStateFlow ) { screenVisible, userPaused, authorized -> if(!authorized) { ProductPlaybackState.ShouldStop }else if (userPaused || !screenVisible) { ProductPlaybackState.ShouldPause } else { ProductPlaybackState.ShouldPlay } } ྫ Single Source of Truth(SSoT)ΛͲ͏͔ͬͨ 11 buildUiModel() immutableͳσʔλΛ ࣋ͭStateFlow ଞͷStateFlowΛҾʹऔΔͷͰ ωετͯ͠ఆٛͰ͖Δ -
AbemaTV, Inc. All Rights Reserved private val productPlaybackStateFlow: StateFlow<ProductPlaybackState> =
buildUiModel( isScreenVisibleStateFlow, isUserPausedStateFlow, isAuthorizedStateFlow ) { screenVisible, userPaused, authorized -> if(!authorized) { ProductPlaybackState.ShouldStop }else if (userPaused || !screenVisible) { ProductPlaybackState.ShouldPause } else { ProductPlaybackState.ShouldPlay } } ྫ Single Source of Truth(SSoT)ΛͲ͏͔ͬͨ 11 buildUiModel() ॳظ͕ϩδοΫʹΑͬͯܭࢉ͞ ΕΔͨΊɺࢦఆ͢Δඞཁ͕ͳ͘ɺ ͜ͷϩδοΫ͕Λ࡞ΔSSoTʹ ͳ͍ͬͯΔ immutableͳσʔλΛ ࣋ͭStateFlow ଞͷStateFlowΛҾʹऔΔͷͰ ωετͯ͠ఆٛͰ͖Δ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ Single Source of Truth(SSoT)ΛͲ͏͔ͬͨ
12 • τϨʔυΦϑ ◦ buildUiModel()ͷҾ͕ଟ͘ͳΓ͗͢Δɺͭ·Γ͏·͘Ͱ͖͍ͯͳ͍ύλʔϯ͕͋ͬͨɻ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ Single Source of Truth(SSoT)ΛͲ͏͔ͬͨ
12 • τϨʔυΦϑ ◦ buildUiModel()ͷҾ͕ଟ͘ͳΓ͗͢Δɺͭ·Γ͏·͘Ͱ͖͍ͯͳ͍ύλʔϯ͕͋ͬͨɻ ▪ 9ݸҎ্૿͞ͳ͍ͱ͍͏੍Λ͚ͭͯɺωετͯ͠͏·͘࡞ΕΔΑ͏ʹͨ͠ɻ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ Single Source of Truth(SSoT)ΛͲ͏͔ͬͨ
12 • τϨʔυΦϑ ◦ buildUiModel()ͷҾ͕ଟ͘ͳΓ͗͢Δɺͭ·Γ͏·͘Ͱ͖͍ͯͳ͍ύλʔϯ͕͋ͬͨɻ ▪ 9ݸҎ্૿͞ͳ͍ͱ͍͏੍Λ͚ͭͯɺωετͯ͠͏·͘࡞ΕΔΑ͏ʹͨ͠ɻ ◦ ͋Δσʔλʹର͢ΔҰ؏ੑอ͍͕ͪ͢ɺྫ͑API͔ΒԿ͔Λऔಘͨ͋͠ͱʹԿΛॻ͖͑Δͷ͔ɺͲ͏Ξϓ ϦέʔγϣϯʹӨڹΛ༩͑Δͷ͔ͷॲཧٯʹ͍ʹ͘͘ͳΔ͔͠Εͳ͍ɻ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ Single Source of Truth(SSoT)ΛͲ͏͔ͬͨ
12 • τϨʔυΦϑ ◦ buildUiModel()ͷҾ͕ଟ͘ͳΓ͗͢Δɺͭ·Γ͏·͘Ͱ͖͍ͯͳ͍ύλʔϯ͕͋ͬͨɻ ▪ 9ݸҎ্૿͞ͳ͍ͱ͍͏੍Λ͚ͭͯɺωετͯ͠͏·͘࡞ΕΔΑ͏ʹͨ͠ɻ ◦ ͋Δσʔλʹର͢ΔҰ؏ੑอ͍͕ͪ͢ɺྫ͑API͔ΒԿ͔Λऔಘͨ͋͠ͱʹԿΛॻ͖͑Δͷ͔ɺͲ͏Ξϓ ϦέʔγϣϯʹӨڹΛ༩͑Δͷ͔ͷॲཧٯʹ͍ʹ͘͘ͳΔ͔͠Εͳ͍ɻ ▪ ͜ΕτϨʔυΦϑͱͯ͠ड͚ೖΕ͍ͯΔɻ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ Single Source of Truth(SSoT)ΛͲ͏͔ͬͨ
12 • τϨʔυΦϑ ◦ buildUiModel()ͷҾ͕ଟ͘ͳΓ͗͢Δɺͭ·Γ͏·͘Ͱ͖͍ͯͳ͍ύλʔϯ͕͋ͬͨɻ ▪ 9ݸҎ্૿͞ͳ͍ͱ͍͏੍Λ͚ͭͯɺωετͯ͠͏·͘࡞ΕΔΑ͏ʹͨ͠ɻ ◦ ͋Δσʔλʹର͢ΔҰ؏ੑอ͍͕ͪ͢ɺྫ͑API͔ΒԿ͔Λऔಘͨ͋͠ͱʹԿΛॻ͖͑Δͷ͔ɺͲ͏Ξϓ ϦέʔγϣϯʹӨڹΛ༩͑Δͷ͔ͷॲཧٯʹ͍ʹ͘͘ͳΔ͔͠Εͳ͍ɻ ▪ ͜ΕτϨʔυΦϑͱͯ͠ड͚ೖΕ͍ͯΔɻ • ସखஈ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ Single Source of Truth(SSoT)ΛͲ͏͔ͬͨ
12 • τϨʔυΦϑ ◦ buildUiModel()ͷҾ͕ଟ͘ͳΓ͗͢Δɺͭ·Γ͏·͘Ͱ͖͍ͯͳ͍ύλʔϯ͕͋ͬͨɻ ▪ 9ݸҎ্૿͞ͳ͍ͱ͍͏੍Λ͚ͭͯɺωετͯ͠͏·͘࡞ΕΔΑ͏ʹͨ͠ɻ ◦ ͋Δσʔλʹର͢ΔҰ؏ੑอ͍͕ͪ͢ɺྫ͑API͔ΒԿ͔Λऔಘͨ͋͠ͱʹԿΛॻ͖͑Δͷ͔ɺͲ͏Ξϓ ϦέʔγϣϯʹӨڹΛ༩͑Δͷ͔ͷॲཧٯʹ͍ʹ͘͘ͳΔ͔͠Εͳ͍ɻ ▪ ͜ΕτϨʔυΦϑͱͯ͠ड͚ೖΕ͍ͯΔɻ • ସखஈ ◦ Cash AppͷMoleculeͰྑ͔ͬͨɻ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ Single Source of Truth(SSoT)ΛͲ͏͔ͬͨ
12 • τϨʔυΦϑ ◦ buildUiModel()ͷҾ͕ଟ͘ͳΓ͗͢Δɺͭ·Γ͏·͘Ͱ͖͍ͯͳ͍ύλʔϯ͕͋ͬͨɻ ▪ 9ݸҎ্૿͞ͳ͍ͱ͍͏੍Λ͚ͭͯɺωετͯ͠͏·͘࡞ΕΔΑ͏ʹͨ͠ɻ ◦ ͋Δσʔλʹର͢ΔҰ؏ੑอ͍͕ͪ͢ɺྫ͑API͔ΒԿ͔Λऔಘͨ͋͠ͱʹԿΛॻ͖͑Δͷ͔ɺͲ͏Ξϓ ϦέʔγϣϯʹӨڹΛ༩͑Δͷ͔ͷॲཧٯʹ͍ʹ͘͘ͳΔ͔͠Εͳ͍ɻ ▪ ͜ΕτϨʔυΦϑͱͯ͠ड͚ೖΕ͍ͯΔɻ • ସखஈ ◦ Cash AppͷMoleculeͰྑ͔ͬͨɻ ▪ ͜ΕΛ͏ͱJetpack ComposeΛͬͯStateFlowΛ࡞ΕΔɻ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ Single Source of Truth(SSoT)ΛͲ͏͔ͬͨ
12 • τϨʔυΦϑ ◦ buildUiModel()ͷҾ͕ଟ͘ͳΓ͗͢Δɺͭ·Γ͏·͘Ͱ͖͍ͯͳ͍ύλʔϯ͕͋ͬͨɻ ▪ 9ݸҎ্૿͞ͳ͍ͱ͍͏੍Λ͚ͭͯɺωετͯ͠͏·͘࡞ΕΔΑ͏ʹͨ͠ɻ ◦ ͋Δσʔλʹର͢ΔҰ؏ੑอ͍͕ͪ͢ɺྫ͑API͔ΒԿ͔Λऔಘͨ͋͠ͱʹԿΛॻ͖͑Δͷ͔ɺͲ͏Ξϓ ϦέʔγϣϯʹӨڹΛ༩͑Δͷ͔ͷॲཧٯʹ͍ʹ͘͘ͳΔ͔͠Εͳ͍ɻ ▪ ͜ΕτϨʔυΦϑͱͯ͠ड͚ೖΕ͍ͯΔɻ • ସखஈ ◦ Cash AppͷMoleculeͰྑ͔ͬͨɻ ▪ ͜ΕΛ͏ͱJetpack ComposeΛͬͯStateFlowΛ࡞ΕΔɻ ▪ ͦΕͧΕͷίϯϙʔωϯτͷUiModelͷ࡞ͳͲΛɺؔʹΓग़͍͕ͨ͠ɺͦ͏ͯ͠େ͖͘ͳ͍ͬͯͬ ͨͱ͖ʹύϑΥʔϚϯε͕Ͳ͏ͳͷ͔ͳͲɺݒ೦͕͋Γ࠾༻Ͱ͖ͳ͔ͬͨɻ(ѱ͍Θ͚Ͱͳ͘ଌΕ͍ͯ ͳ͍͚ͩͰ͢ɻ) -
AbemaTV, Inc. All Rights Reserved ϝϦοτ Android Developersʹ͋Δઃܭ֓೦ Λࢀর Unidirectional
Data Flow(UDF)ͱ 14 https://developer.android.com/topic/architecture#unidirectional-data-flow -
AbemaTV, Inc. All Rights Reserved ϝϦοτ Android Developersʹ͋Δઃܭ֓೦ Λࢀর Unidirectional
Data Flow(UDF)ͱ 14 • Guide to App Architectureͷ Common architectural principlesͷҰ ͭ https://developer.android.com/topic/architecture#unidirectional-data-flow -
AbemaTV, Inc. All Rights Reserved ϝϦοτ Android Developersʹ͋Δઃܭ֓೦ Λࢀর Unidirectional
Data Flow(UDF)ͱ 14 • Guide to App Architectureͷ Common architectural principlesͷҰ ͭ • ϙΠϯτ https://developer.android.com/topic/architecture#unidirectional-data-flow -
AbemaTV, Inc. All Rights Reserved ϝϦοτ Android Developersʹ͋Δઃܭ֓೦ Λࢀর Unidirectional
Data Flow(UDF)ͱ 14 • Guide to App Architectureͷ Common architectural principlesͷҰ ͭ • ϙΠϯτ ◦ State͕ҰํʹྲྀΕɺ Event͕ٯଆʹྲྀΕΔɻ https://developer.android.com/topic/architecture#unidirectional-data-flow -
AbemaTV, Inc. All Rights Reserved ϝϦοτ Android Developersʹ͋Δઃܭ֓೦ Λࢀর Unidirectional
Data Flow(UDF)ͱ 14 • Guide to App Architectureͷ Common architectural principlesͷҰ ͭ • ϙΠϯτ ◦ State͕ҰํʹྲྀΕɺ Event͕ٯଆʹྲྀΕΔɻ • SSoTʹΑͬͯಘΒΕΔརӹɻ https://developer.android.com/topic/architecture#unidirectional-data-flow -
AbemaTV, Inc. All Rights Reserved ϝϦοτ Android Developersʹ͋Δઃܭ֓೦ Λࢀর Unidirectional
Data Flow(UDF)ͱ 14 • Guide to App Architectureͷ Common architectural principlesͷҰ ͭ • ϙΠϯτ ◦ State͕ҰํʹྲྀΕɺ Event͕ٯଆʹྲྀΕΔɻ • SSoTʹΑͬͯಘΒΕΔརӹɻ • Ұ؏ੑɺޡΓΛݮΒ͢ɺσόοάΛָ ʹ͢Δ https://developer.android.com/topic/architecture#unidirectional-data-flow -
AbemaTV, Inc. All Rights Reserved ͱͱͷ࣮ͷ Unidirectional Data Flow(UDF)ΛͲ͏͔ͬͨ 15
• FragmentRecyclerViewͷΞΠςϜ·Ͱɺ͞ ·͟·ͳͱ͜Ζʹಉ͡ViewModel͕Ͱͯ͘Δ࣮ ʹͳ͍ͬͯͯσʔλͷྲྀΕ͕౷Ұ͞Ε͍ͯͳ ͔ͬͨɻ͜ΕʹΑΓɺσόοάͳͲ͕͘͠ͳ ΔͳͲ͕ൃੜ͍ͯͨ͠ɻ -
AbemaTV, Inc. All Rights Reserved ͱͱͷ࣮ͷ Unidirectional Data Flow(UDF)ΛͲ͏͔ͬͨ 16
• ৽͍͠Jetpack Compose ͔ ࣮ͷAndroid View ͔ɺͲͪΒΛ͏͔ɻ -
AbemaTV, Inc. All Rights Reserved ͱͱͷ࣮ͷ Unidirectional Data Flow(UDF)ΛͲ͏͔ͬͨ 16
• ৽͍͠Jetpack Compose ͔ ࣮ͷAndroid View ͔ɺͲͪΒΛ͏͔ɻ ◦ ͠ऴ൫ʹக໋తͳ͕ݟ͔ͭΔͱऔΓฦ͕͔ͭ͠ͳ͔ͬͨͷͰɺ දࣔͷج൫ͱͳΔ෦ʹΞϓϦͰ࣮ͷ͋ΔAndroid ViewΛ͍ͨ ͔ͬͨɻ -
AbemaTV, Inc. All Rights Reserved ͱͱͷ࣮ͷ Unidirectional Data Flow(UDF)ΛͲ͏͔ͬͨ 16
• ৽͍͠Jetpack Compose ͔ ࣮ͷAndroid View ͔ɺͲͪΒΛ͏͔ɻ ◦ ͠ऴ൫ʹக໋తͳ͕ݟ͔ͭΔͱऔΓฦ͕͔ͭ͠ͳ͔ͬͨͷͰɺ දࣔͷج൫ͱͳΔ෦ʹΞϓϦͰ࣮ͷ͋ΔAndroid ViewΛ͍ͨ ͔ͬͨɻ ◦ ࠓޙͷJetpack ComposeͱͷޓੑΛͲ͏୲อ͢Δ͔ʁ -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ Unidirectional Data Flow(UDF)ΛͲ͏͔ͬͨ 17
class ViewBinder( private val binding: PlayerBinding, onUserPlayerPaused: () -> Unit ) { fun apply(uiModel: PlayerUiModel) { binding.title.text = uiModel.title binding.pauseButton.setOnClickListener { onUserPlayerPaused() } } } -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ Unidirectional Data Flow(UDF)ΛͲ͏͔ͬͨ 17
• ViewBinderͱ͍͏ΫϥεΛఆٛͨ͠ɻ class ViewBinder( private val binding: PlayerBinding, onUserPlayerPaused: () -> Unit ) { fun apply(uiModel: PlayerUiModel) { binding.title.text = uiModel.title binding.pauseButton.setOnClickListener { onUserPlayerPaused() } } } -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ Unidirectional Data Flow(UDF)ΛͲ͏͔ͬͨ 17
• ViewBinderͱ͍͏ΫϥεΛఆٛͨ͠ɻ ◦ ͜ͷΫϥεʹҾʹViewModelͳͲ Λ͞ͳ͍ͱ͍͏੍Λ͚ͭͯɺView جຊతʹ͜ͷதͰมߋΛՃ͑Δɻ class ViewBinder( private val binding: PlayerBinding, onUserPlayerPaused: () -> Unit ) { fun apply(uiModel: PlayerUiModel) { binding.title.text = uiModel.title binding.pauseButton.setOnClickListener { onUserPlayerPaused() } } } -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ Unidirectional Data Flow(UDF)ΛͲ͏͔ͬͨ 17
• ViewBinderͱ͍͏ΫϥεΛఆٛͨ͠ɻ ◦ ͜ͷΫϥεʹҾʹViewModelͳͲ Λ͞ͳ͍ͱ͍͏੍Λ͚ͭͯɺView جຊతʹ͜ͷதͰมߋΛՃ͑Δɻ ◦ Jetpack ComposeʹҠߦ͠ऴΘΕফ ͤΔΫϥεɻ class ViewBinder( private val binding: PlayerBinding, onUserPlayerPaused: () -> Unit ) { fun apply(uiModel: PlayerUiModel) { binding.title.text = uiModel.title binding.pauseButton.setOnClickListener { onUserPlayerPaused() } } } -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ Unidirectional Data Flow(UDF)ΛͲ͏͔ͬͨ 18
class ViewBinder( private val binding: PlayerBinding, onUserPlayerPaused: () -> Unit ) { fun apply(uiModel: PlayerUiModel) { binding.title.text = uiModel.title binding.pauseButton.setOnClickListener { onUserPlayerPaused() } } } ͨͩͷγϯϓϧͳΫϥε -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ Unidirectional Data Flow(UDF)ΛͲ͏͔ͬͨ 18
class ViewBinder( private val binding: PlayerBinding, onUserPlayerPaused: () -> Unit ) { fun apply(uiModel: PlayerUiModel) { binding.title.text = uiModel.title binding.pauseButton.setOnClickListener { onUserPlayerPaused() } } } ݺͼݩ͔Βσʔλ͕͞ΕΔ buildUiModel()ʹΑͬͯ౷߹͞Εͨ UiModel͕ͬͯ͘ΔͷͰɺ apply()ؔҰͭͷΈʹͳΓγϯϓϧ ͨͩͷγϯϓϧͳΫϥε -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ Unidirectional Data Flow(UDF)ΛͲ͏͔ͬͨ 18
class ViewBinder( private val binding: PlayerBinding, onUserPlayerPaused: () -> Unit ) { fun apply(uiModel: PlayerUiModel) { binding.title.text = uiModel.title binding.pauseButton.setOnClickListener { onUserPlayerPaused() } } } ݺͼݩ͔Βσʔλ͕͞ΕΔ ݺͼݩʹΠϕϯτΛ͢ buildUiModel()ʹΑͬͯ౷߹͞Εͨ UiModel͕ͬͯ͘ΔͷͰɺ apply()ؔҰͭͷΈʹͳΓγϯϓϧ ͨͩͷγϯϓϧͳΫϥε -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ Unidirectional Data Flow(UDF)ΛͲ͏͔ͬͨ 20
• τϨʔυΦϑ ◦ ViewBinderͱ͍͏ଘࡏࣗମ͕ೃછΈ͕ͳ͍ͷͰֶशίετ্͕͕Δɻ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ Unidirectional Data Flow(UDF)ΛͲ͏͔ͬͨ 20
• τϨʔυΦϑ ◦ ViewBinderͱ͍͏ଘࡏࣗମ͕ೃછΈ͕ͳ͍ͷͰֶशίετ্͕͕Δɻ ◦ ViewBinderΫϥεͷҾ͕Πϕϯτͷ͚ͩͰ͖ΔͷͰଟ͘ͳΓ͕ͪ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ Unidirectional Data Flow(UDF)ΛͲ͏͔ͬͨ 20
• τϨʔυΦϑ ◦ ViewBinderͱ͍͏ଘࡏࣗମ͕ೃછΈ͕ͳ͍ͷͰֶशίετ্͕͕Δɻ ◦ ViewBinderΫϥεͷҾ͕Πϕϯτͷ͚ͩͰ͖ΔͷͰଟ͘ͳΓ͕ͪ ▪ → ໊લ͖ҾʹͳΓɺ͍͍͢ͷͰɺͦ͜·ͰͷʹͳΒͳ͍ͣɻ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ Unidirectional Data Flow(UDF)ΛͲ͏͔ͬͨ 20
• τϨʔυΦϑ ◦ ViewBinderͱ͍͏ଘࡏࣗମ͕ೃછΈ͕ͳ͍ͷͰֶशίετ্͕͕Δɻ ◦ ViewBinderΫϥεͷҾ͕Πϕϯτͷ͚ͩͰ͖ΔͷͰଟ͘ͳΓ͕ͪ ▪ → ໊લ͖ҾʹͳΓɺ͍͍͢ͷͰɺͦ͜·ͰͷʹͳΒͳ͍ͣɻ ◦ ViewBinderͷதʹView͚ͩͰͳ͘Composeೖ͍ͬͯͨͷͰɺComposeͰΛ͢ͱ͖ʹStateFlowΛ͢ඞཁ͕͋ͬ ͕ͨStateFlowViewBinderʹ͢ඞཁ͕͋ͬͨͷͰɺͦΕʹΑͬͯదԠํ๏͕ࢄͯ͠͠·͍ͬͯͨɻ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ Unidirectional Data Flow(UDF)ΛͲ͏͔ͬͨ 20
• τϨʔυΦϑ ◦ ViewBinderͱ͍͏ଘࡏࣗମ͕ೃછΈ͕ͳ͍ͷͰֶशίετ্͕͕Δɻ ◦ ViewBinderΫϥεͷҾ͕Πϕϯτͷ͚ͩͰ͖ΔͷͰଟ͘ͳΓ͕ͪ ▪ → ໊લ͖ҾʹͳΓɺ͍͍͢ͷͰɺͦ͜·ͰͷʹͳΒͳ͍ͣɻ ◦ ViewBinderͷதʹView͚ͩͰͳ͘Composeೖ͍ͬͯͨͷͰɺComposeͰΛ͢ͱ͖ʹStateFlowΛ͢ඞཁ͕͋ͬ ͕ͨStateFlowViewBinderʹ͢ඞཁ͕͋ͬͨͷͰɺͦΕʹΑͬͯదԠํ๏͕ࢄͯ͠͠·͍ͬͯͨɻ ▪ → ͏·͘StateFlowͷΈͰಈ͔͢Α͏ʹ͢ΔͳͲͷΈ͕ඞཁɻ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ Unidirectional Data Flow(UDF)ΛͲ͏͔ͬͨ 20
• τϨʔυΦϑ ◦ ViewBinderͱ͍͏ଘࡏࣗମ͕ೃછΈ͕ͳ͍ͷͰֶशίετ্͕͕Δɻ ◦ ViewBinderΫϥεͷҾ͕Πϕϯτͷ͚ͩͰ͖ΔͷͰଟ͘ͳΓ͕ͪ ▪ → ໊લ͖ҾʹͳΓɺ͍͍͢ͷͰɺͦ͜·ͰͷʹͳΒͳ͍ͣɻ ◦ ViewBinderͷதʹView͚ͩͰͳ͘Composeೖ͍ͬͯͨͷͰɺComposeͰΛ͢ͱ͖ʹStateFlowΛ͢ඞཁ͕͋ͬ ͕ͨStateFlowViewBinderʹ͢ඞཁ͕͋ͬͨͷͰɺͦΕʹΑͬͯదԠํ๏͕ࢄͯ͠͠·͍ͬͯͨɻ ▪ → ͏·͘StateFlowͷΈͰಈ͔͢Α͏ʹ͢ΔͳͲͷΈ͕ඞཁɻ ◦ ࡉ͔͍ͷมԽͰͯ͢ΛViewBinder.apply()ͰViewʹదԠ͢͠ͷͰύϑΥʔϚϯεతʹ·ͣͦ͏Ͱʁ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ Unidirectional Data Flow(UDF)ΛͲ͏͔ͬͨ 20
• τϨʔυΦϑ ◦ ViewBinderͱ͍͏ଘࡏࣗମ͕ೃછΈ͕ͳ͍ͷͰֶशίετ্͕͕Δɻ ◦ ViewBinderΫϥεͷҾ͕Πϕϯτͷ͚ͩͰ͖ΔͷͰଟ͘ͳΓ͕ͪ ▪ → ໊લ͖ҾʹͳΓɺ͍͍͢ͷͰɺͦ͜·ͰͷʹͳΒͳ͍ͣɻ ◦ ViewBinderͷதʹView͚ͩͰͳ͘Composeೖ͍ͬͯͨͷͰɺComposeͰΛ͢ͱ͖ʹStateFlowΛ͢ඞཁ͕͋ͬ ͕ͨStateFlowViewBinderʹ͢ඞཁ͕͋ͬͨͷͰɺͦΕʹΑͬͯదԠํ๏͕ࢄͯ͠͠·͍ͬͯͨɻ ▪ → ͏·͘StateFlowͷΈͰಈ͔͢Α͏ʹ͢ΔͳͲͷΈ͕ඞཁɻ ◦ ࡉ͔͍ͷมԽͰͯ͢ΛViewBinder.apply()ͰViewʹదԠ͢͠ͷͰύϑΥʔϚϯεతʹ·ͣͦ͏Ͱʁ ▪ → (࣍ϖʔδ) -
AbemaTV, Inc. All Rights Reserved ύϑΥʔϚϯεతʹ·ͣͦ͏ͱ͍͏ Unidirectional Data Flow(UDF)ΛͲ͏͔ͬͨ 21
ViewBinder.apply()Λେ͖ͳ୯ҐͰΒͤΔͱɺ ྫ͑TextView͕தʹ͋Δͱɺ wrap_contentͷ߹ಉ͡ςΩετͰ requestLayout()͕ΓશମΛϨΠΞτ͢͠ → ԿΒ͔ͷࠩߋ৽͕ඞཁͦ͏ fun apply(uiModel: PlayerUiModel) { binding.title.text = uiModel.title … } textView.setText()͔ΒrequestLayout()͕ݺΕ͍ͯΔྫ -
AbemaTV, Inc. All Rights Reserved ύϑΥʔϚϯεʹؔͯ͠ɺJetpack Compose͕෦తʹߦ͍ͬͯΔΞϓϩʔν Unidirectional Data Flow(UDF)ΛͲ͏͔ͬͨ
22 • Jetpack ComposeͰঢ়ଶΛComposableؔຖʹ͍࣋ͬͯͯ(SlotTable)ɺؔͷҾ͕มΘͬͨ࣌ͷΈؔதͷॲཧΛ ߦ͏ɻ(͍ΘΏΔdonut-hole skipping) -
AbemaTV, Inc. All Rights Reserved ύϑΥʔϚϯεʹؔͯ͠ɺJetpack Compose͕෦తʹߦ͍ͬͯΔΞϓϩʔν Unidirectional Data Flow(UDF)ΛͲ͏͔ͬͨ
22 • Jetpack ComposeͰঢ়ଶΛComposableؔຖʹ͍࣋ͬͯͯ(SlotTable)ɺؔͷҾ͕มΘͬͨ࣌ͷΈؔதͷॲཧΛ ߦ͏ɻ(͍ΘΏΔdonut-hole skipping) inline fun <reified T> View.updateTag( @IdRes tagId: Int, value: T, onUpdate: (old: T?, new: T) -> Unit ) { val old: T? = getTag(tagId) as? T if (old != value) { setTag(tagId, value) onUpdate(old, value) } } -
AbemaTV, Inc. All Rights Reserved ύϑΥʔϚϯεʹؔͯ͠ɺJetpack Compose͕෦తʹߦ͍ͬͯΔΞϓϩʔν Unidirectional Data Flow(UDF)ΛͲ͏͔ͬͨ
22 • Jetpack ComposeͰঢ়ଶΛComposableؔຖʹ͍࣋ͬͯͯ(SlotTable)ɺؔͷҾ͕มΘͬͨ࣌ͷΈؔதͷॲཧΛ ߦ͏ɻ(͍ΘΏΔdonut-hole skipping) inline fun <reified T> View.updateTag( @IdRes tagId: Int, value: T, onUpdate: (old: T?, new: T) -> Unit ) { val old: T? = getTag(tagId) as? T if (old != value) { setTag(tagId, value) onUpdate(old, value) } } • ͜ΕΛٖࣅతʹViewͰͰ͖ͳ͍͔ʁ -
AbemaTV, Inc. All Rights Reserved ύϑΥʔϚϯεʹؔͯ͠ɺJetpack Compose͕෦తʹߦ͍ͬͯΔΞϓϩʔν Unidirectional Data Flow(UDF)ΛͲ͏͔ͬͨ
22 • Jetpack ComposeͰঢ়ଶΛComposableؔຖʹ͍࣋ͬͯͯ(SlotTable)ɺؔͷҾ͕มΘͬͨ࣌ͷΈؔதͷॲཧΛ ߦ͏ɻ(͍ΘΏΔdonut-hole skipping) inline fun <reified T> View.updateTag( @IdRes tagId: Int, value: T, onUpdate: (old: T?, new: T) -> Unit ) { val old: T? = getTag(tagId) as? T if (old != value) { setTag(tagId, value) onUpdate(old, value) } } • ͜ΕΛٖࣅతʹViewͰͰ͖ͳ͍͔ʁ ◦ View.updateTag { }ͱ͍͏ؔΛ࡞ -
AbemaTV, Inc. All Rights Reserved ύϑΥʔϚϯεʹؔͯ͠ɺJetpack Compose͕෦తʹߦ͍ͬͯΔΞϓϩʔν Unidirectional Data Flow(UDF)ΛͲ͏͔ͬͨ
22 • Jetpack ComposeͰঢ়ଶΛComposableؔຖʹ͍࣋ͬͯͯ(SlotTable)ɺؔͷҾ͕มΘͬͨ࣌ͷΈؔதͷॲཧΛ ߦ͏ɻ(͍ΘΏΔdonut-hole skipping) inline fun <reified T> View.updateTag( @IdRes tagId: Int, value: T, onUpdate: (old: T?, new: T) -> Unit ) { val old: T? = getTag(tagId) as? T if (old != value) { setTag(tagId, value) onUpdate(old, value) } } • ͜ΕΛٖࣅతʹViewͰͰ͖ͳ͍͔ʁ ◦ View.updateTag { }ͱ͍͏ؔΛ࡞ ▪ Viewͷอ࣋͢ΔtagΛར༻ͯ͠ ͕ࠩ͋Ε͞ΕͨؔΛݺͿ -
AbemaTV, Inc. All Rights Reserved ύϑΥʔϚϯεʹؔͯ͠ɺJetpack Compose͕෦తʹߦ͍ͬͯΔΞϓϩʔν Unidirectional Data Flow(UDF)ΛͲ͏͔ͬͨ
22 • Jetpack ComposeͰঢ়ଶΛComposableؔຖʹ͍࣋ͬͯͯ(SlotTable)ɺؔͷҾ͕มΘͬͨ࣌ͷΈؔதͷॲཧΛ ߦ͏ɻ(͍ΘΏΔdonut-hole skipping) inline fun <reified T> View.updateTag( @IdRes tagId: Int, value: T, onUpdate: (old: T?, new: T) -> Unit ) { val old: T? = getTag(tagId) as? T if (old != value) { setTag(tagId, value) onUpdate(old, value) } } • ͜ΕΛٖࣅతʹViewͰͰ͖ͳ͍͔ʁ ◦ View.updateTag { }ͱ͍͏ؔΛ࡞ ▪ Viewͷอ࣋͢ΔtagΛར༻ͯ͠ ͕ࠩ͋Ε͞ΕͨؔΛݺͿ ▪ ͜ΕΛViewBinder.apply()ͷதͰɺ ར༻͍ͯ͘͜͠ͱͰղܾɻ -
AbemaTV, Inc. All Rights Reserved ϝϦοτ Android Developersͷ Recommendations for
Android architectureΑΓ “ViewModel͔ΒUIʹΠϕϯτΛૹΒͳ͍”ͱ 24 https://developer.android.com/topic/architecture/ recommendations?hl=en -
AbemaTV, Inc. All Rights Reserved ϝϦοτ Android Developersͷ Recommendations for
Android architectureΑΓ “ViewModel͔ΒUIʹΠϕϯτΛૹΒͳ͍”ͱ 24 • UI layerʹ͋Δ߲ͰɺStrongly recommended https://developer.android.com/topic/architecture/ recommendations?hl=en -
AbemaTV, Inc. All Rights Reserved ϝϦοτ Android Developersͷ Recommendations for
Android architectureΑΓ “ViewModel͔ΒUIʹΠϕϯτΛૹΒͳ͍”ͱ 24 • UI layerʹ͋Δ߲ͰɺStrongly recommended • ϙΠϯτ https://developer.android.com/topic/architecture/ recommendations?hl=en -
AbemaTV, Inc. All Rights Reserved ϝϦοτ Android Developersͷ Recommendations for
Android architectureΑΓ “ViewModel͔ΒUIʹΠϕϯτΛૹΒͳ͍”ͱ 24 • UI layerʹ͋Δ߲ͰɺStrongly recommended • ϙΠϯτ ◦ UIͷΞΫγϣϯΠϕϯτͰͳ ͘ɺUI StateͷΞοϓσʔτʹ ΑͬͯߦΘΕΔ͖ɻ https://developer.android.com/topic/architecture/ recommendations?hl=en -
AbemaTV, Inc. All Rights Reserved ϝϦοτ Android Developersͷ Recommendations for
Android architectureΑΓ “ViewModel͔ΒUIʹΠϕϯτΛૹΒͳ͍”ͱ 24 • UI layerʹ͋Δ߲ͰɺStrongly recommended • ϙΠϯτ ◦ UIͷΞΫγϣϯΠϕϯτͰͳ ͘ɺUI StateͷΞοϓσʔτʹ ΑͬͯߦΘΕΔ͖ɻ • Πϕϯτ͕࠶ݱՄೳʹͳΔɻ https://developer.android.com/topic/architecture/ recommendations?hl=en -
AbemaTV, Inc. All Rights Reserved ϝϦοτ Android Developersͷ Recommendations for
Android architectureΑΓ “ViewModel͔ΒUIʹΠϕϯτΛૹΒͳ͍”ͱ 24 • UI layerʹ͋Δ߲ͰɺStrongly recommended • ϙΠϯτ ◦ UIͷΞΫγϣϯΠϕϯτͰͳ ͘ɺUI StateͷΞοϓσʔτʹ ΑͬͯߦΘΕΔ͖ɻ • Πϕϯτ͕࠶ݱՄೳʹͳΔɻ • UIΞΫγϣϯ͕ࣦΘΕͳ͍͜ͱ͕อূ ͞ΕΔɻ https://developer.android.com/topic/architecture/ recommendations?hl=en -
AbemaTV, Inc. All Rights Reserved ͱͱͷ࣮ͷ “ViewModel͔ΒUIʹΠϕϯτΛૹΒͳ͍”ΛͲ͏͔ͬͨ 25 • collect{}ͷλΠϛϯάͳͲͰɺSharedFlowΛ͏ίʔυͰόά͕ى͖Δ͜ͱ͕
͋ͬͨɻ ◦ ྫ͑ɺreplay=0ͷ߹ɺrepeatOnLifecycle(Lifecycle.State.STARTED)ͳ ͲΛ͍ͬͯͯɺΠϕϯτ͕STARTEDҎલʹૹΒΕΔͱফ͑ΔͳͲ -
AbemaTV, Inc. All Rights Reserved ͱͱͷ࣮ͷ “ViewModel͔ΒUIʹΠϕϯτΛૹΒͳ͍”ΛͲ͏͔ͬͨ 25 • collect{}ͷλΠϛϯάͳͲͰɺSharedFlowΛ͏ίʔυͰόά͕ى͖Δ͜ͱ͕
͋ͬͨɻ ◦ ྫ͑ɺreplay=0ͷ߹ɺrepeatOnLifecycle(Lifecycle.State.STARTED)ͳ ͲΛ͍ͬͯͯɺΠϕϯτ͕STARTEDҎલʹૹΒΕΔͱফ͑ΔͳͲ • ·ͨɺςετͩͱFake͕ૣ͘σʔλΛฦ͢ӨڹͰɺࢠͷFragmentͰσʔλΛड ͚औΔલʹSharedFlow͕ൃՐ͢ΔͳͲςετ͍͠ύλʔϯ͕͋Δ -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ “ViewModel͔ΒUIʹΠϕϯτΛૹΒͳ͍”ΛͲ͏͔ͬͨ 27 // ViewBinder.apply()ͷத
if (alertRequestStates.showPlaybackErrorAlertRequestState.isRequested()) { onShowPlaybackErrorAlert() showSnackbar(message) } // ViewModel val showPlaybackErrorAlertRequestState = MutableStateFlow(RequestState.NotRequested) fun hoge() { try { ... } catch(e: PlaybackError) { showPlaybackErrorAlertRequestState.value = RequestState.Requested(PlaybackErrorAlert) } } fun onShowPlaybackErrorAlert() { showPlaybackErrorAlertRequestState.value = RequestState.NotRequested } -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ “ViewModel͔ΒUIʹΠϕϯτΛૹΒͳ͍”ΛͲ͏͔ͬͨ 27 // ViewBinder.apply()ͷத
if (alertRequestStates.showPlaybackErrorAlertRequestState.isRequested()) { onShowPlaybackErrorAlert() showSnackbar(message) } // ViewModel val showPlaybackErrorAlertRequestState = MutableStateFlow(RequestState.NotRequested) fun hoge() { try { ... } catch(e: PlaybackError) { showPlaybackErrorAlertRequestState.value = RequestState.Requested(PlaybackErrorAlert) } } fun onShowPlaybackErrorAlert() { showPlaybackErrorAlertRequestState.value = RequestState.NotRequested } ᶃ StateFlowΛఆٛ -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ “ViewModel͔ΒUIʹΠϕϯτΛૹΒͳ͍”ΛͲ͏͔ͬͨ 27 // ViewBinder.apply()ͷத
if (alertRequestStates.showPlaybackErrorAlertRequestState.isRequested()) { onShowPlaybackErrorAlert() showSnackbar(message) } // ViewModel val showPlaybackErrorAlertRequestState = MutableStateFlow(RequestState.NotRequested) fun hoge() { try { ... } catch(e: PlaybackError) { showPlaybackErrorAlertRequestState.value = RequestState.Requested(PlaybackErrorAlert) } } fun onShowPlaybackErrorAlert() { showPlaybackErrorAlertRequestState.value = RequestState.NotRequested } ᶃ StateFlowΛఆٛ ᶄ RequestedΛηοτ -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ “ViewModel͔ΒUIʹΠϕϯτΛૹΒͳ͍”ΛͲ͏͔ͬͨ 27 // ViewBinder.apply()ͷத
if (alertRequestStates.showPlaybackErrorAlertRequestState.isRequested()) { onShowPlaybackErrorAlert() showSnackbar(message) } // ViewModel val showPlaybackErrorAlertRequestState = MutableStateFlow(RequestState.NotRequested) fun hoge() { try { ... } catch(e: PlaybackError) { showPlaybackErrorAlertRequestState.value = RequestState.Requested(PlaybackErrorAlert) } } fun onShowPlaybackErrorAlert() { showPlaybackErrorAlertRequestState.value = RequestState.NotRequested } ᶃ StateFlowΛఆٛ ᶄ RequestedΛηοτ ᶅ RequestedʹͳͬͨͷΛ ফඅ͢Δ -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ “ViewModel͔ΒUIʹΠϕϯτΛૹΒͳ͍”ΛͲ͏͔ͬͨ 27 // ViewBinder.apply()ͷத
if (alertRequestStates.showPlaybackErrorAlertRequestState.isRequested()) { onShowPlaybackErrorAlert() showSnackbar(message) } // ViewModel val showPlaybackErrorAlertRequestState = MutableStateFlow(RequestState.NotRequested) fun hoge() { try { ... } catch(e: PlaybackError) { showPlaybackErrorAlertRequestState.value = RequestState.Requested(PlaybackErrorAlert) } } fun onShowPlaybackErrorAlert() { showPlaybackErrorAlertRequestState.value = RequestState.NotRequested } ᶃ StateFlowΛఆٛ ᶄ RequestedΛηοτ ᶅ RequestedʹͳͬͨͷΛ ফඅ͢Δ ᶆ NotRequestedʹ͢ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ “ViewModel͔ΒUIʹΠϕϯτΛૹΒͳ͍”ΛͲ͏͔ͬͨ 28 • τϨʔυΦϑ
◦ ίʔυ͕૿͑Δมߋɻ ▪ ϘΠϥʔϓϨʔτͬΆ͍ײ͋͡ΔͷͰɺͲͷStateΛม͍͑ͯΔ͔ͳͲҙਤͨ͠มߋͳͷ͔Ͳ͏͔Ϩ Ϗϡʔ͢Δඞཁ͕͋Δɻ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ “ViewModel͔ΒUIʹΠϕϯτΛૹΒͳ͍”ΛͲ͏͔ͬͨ 28 • τϨʔυΦϑ
◦ ίʔυ͕૿͑Δมߋɻ ▪ ϘΠϥʔϓϨʔτͬΆ͍ײ͋͡ΔͷͰɺͲͷStateΛม͍͑ͯΔ͔ͳͲҙਤͨ͠มߋͳͷ͔Ͳ͏͔Ϩ Ϗϡʔ͢Δඞཁ͕͋Δɻ ▪ ΘΓʹϓϨΠϠʔͷStateͳͲͰ໌֬ʹSingle Source of Truth͕࡞ΒΕͨͨΊɺ໌Β͔ʹཧ͘͢͠ ͳͬͨײ͕͋͡Δɻ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ “ViewModel͔ΒUIʹΠϕϯτΛૹΒͳ͍”ΛͲ͏͔ͬͨ 28 • τϨʔυΦϑ
◦ ίʔυ͕૿͑Δมߋɻ ▪ ϘΠϥʔϓϨʔτͬΆ͍ײ͋͡ΔͷͰɺͲͷStateΛม͍͑ͯΔ͔ͳͲҙਤͨ͠มߋͳͷ͔Ͳ͏͔Ϩ Ϗϡʔ͢Δඞཁ͕͋Δɻ ▪ ΘΓʹϓϨΠϠʔͷStateͳͲͰ໌֬ʹSingle Source of Truth͕࡞ΒΕͨͨΊɺ໌Β͔ʹཧ͘͢͠ ͳͬͨײ͕͋͡Δɻ ▪ ίʔυͷ౷ҰײͰ͖ͨɻComposeͷLaunchedEffect()ͳͲʹޓੑ͕͋Δͣɻ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ “ViewModel͔ΒUIʹΠϕϯτΛૹΒͳ͍”ΛͲ͏͔ͬͨ 28 • τϨʔυΦϑ
◦ ίʔυ͕૿͑Δมߋɻ ▪ ϘΠϥʔϓϨʔτͬΆ͍ײ͋͡ΔͷͰɺͲͷStateΛม͍͑ͯΔ͔ͳͲҙਤͨ͠มߋͳͷ͔Ͳ͏͔Ϩ Ϗϡʔ͢Δඞཁ͕͋Δɻ ▪ ΘΓʹϓϨΠϠʔͷStateͳͲͰ໌֬ʹSingle Source of Truth͕࡞ΒΕͨͨΊɺ໌Β͔ʹཧ͘͢͠ ͳͬͨײ͕͋͡Δɻ ▪ ίʔυͷ౷ҰײͰ͖ͨɻComposeͷLaunchedEffect()ͳͲʹޓੑ͕͋Δͣɻ • ସखஈ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ “ViewModel͔ΒUIʹΠϕϯτΛૹΒͳ͍”ΛͲ͏͔ͬͨ 28 • τϨʔυΦϑ
◦ ίʔυ͕૿͑Δมߋɻ ▪ ϘΠϥʔϓϨʔτͬΆ͍ײ͋͡ΔͷͰɺͲͷStateΛม͍͑ͯΔ͔ͳͲҙਤͨ͠มߋͳͷ͔Ͳ͏͔Ϩ Ϗϡʔ͢Δඞཁ͕͋Δɻ ▪ ΘΓʹϓϨΠϠʔͷStateͳͲͰ໌֬ʹSingle Source of Truth͕࡞ΒΕͨͨΊɺ໌Β͔ʹཧ͘͢͠ ͳͬͨײ͕͋͡Δɻ ▪ ίʔυͷ౷ҰײͰ͖ͨɻComposeͷLaunchedEffect()ͳͲʹޓੑ͕͋Δͣɻ • ସखஈ ◦ UiModelʹมߋ͢ΔͨΊͷϥϜμΛ͢Α͏ͳΓํࢼͯ͠Έͯྑ͍͔͠Εͳ͍ɻ˞ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ “ViewModel͔ΒUIʹΠϕϯτΛૹΒͳ͍”ΛͲ͏͔ͬͨ 28 • τϨʔυΦϑ
◦ ίʔυ͕૿͑Δมߋɻ ▪ ϘΠϥʔϓϨʔτͬΆ͍ײ͋͡ΔͷͰɺͲͷStateΛม͍͑ͯΔ͔ͳͲҙਤͨ͠มߋͳͷ͔Ͳ͏͔Ϩ Ϗϡʔ͢Δඞཁ͕͋Δɻ ▪ ΘΓʹϓϨΠϠʔͷStateͳͲͰ໌֬ʹSingle Source of Truth͕࡞ΒΕͨͨΊɺ໌Β͔ʹཧ͘͢͠ ͳͬͨײ͕͋͡Δɻ ▪ ίʔυͷ౷ҰײͰ͖ͨɻComposeͷLaunchedEffect()ͳͲʹޓੑ͕͋Δͣɻ • ସखஈ ◦ UiModelʹมߋ͢ΔͨΊͷϥϜμΛ͢Α͏ͳΓํࢼͯ͠Έͯྑ͍͔͠Εͳ͍ɻ˞ ※ https://developer.android.com/topic/architecture/ui-layer/events#recyclerview-events -
AbemaTV, Inc. All Rights Reserved GoogleͷDIϥΠϒϥϦ Dagger Hiltͷ υΩϡϝϯτͷHilt Testing
PhilosophyΑΓ ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏ 30 ϝϦοτ https://dagger.dev/hilt/testing-philosophy.html ΑΓ -
AbemaTV, Inc. All Rights Reserved GoogleͷDIϥΠϒϥϦ Dagger Hiltͷ υΩϡϝϯτͷHilt Testing
PhilosophyΑΓ ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏ 30 • ҎԼͷॱ൪Ͱ͏ ϝϦοτ https://dagger.dev/hilt/testing-philosophy.html ΑΓ -
AbemaTV, Inc. All Rights Reserved GoogleͷDIϥΠϒϥϦ Dagger Hiltͷ υΩϡϝϯτͷHilt Testing
PhilosophyΑΓ ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏ 30 • ҎԼͷॱ൪Ͱ͏ ◦ ຊͷΦϒδΣΫτ ϝϦοτ https://dagger.dev/hilt/testing-philosophy.html ΑΓ -
AbemaTV, Inc. All Rights Reserved GoogleͷDIϥΠϒϥϦ Dagger Hiltͷ υΩϡϝϯτͷHilt Testing
PhilosophyΑΓ ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏ 30 • ҎԼͷॱ൪Ͱ͏ ◦ ຊͷΦϒδΣΫτ ◦ ϥΠϒϥϦ͕ఏڙ͢ΔFake ϝϦοτ https://dagger.dev/hilt/testing-philosophy.html ΑΓ -
AbemaTV, Inc. All Rights Reserved GoogleͷDIϥΠϒϥϦ Dagger Hiltͷ υΩϡϝϯτͷHilt Testing
PhilosophyΑΓ ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏ 30 • ҎԼͷॱ൪Ͱ͏ ◦ ຊͷΦϒδΣΫτ ◦ ϥΠϒϥϦ͕ఏڙ͢ΔFake ◦ Mock ϝϦοτ https://dagger.dev/hilt/testing-philosophy.html ΑΓ -
AbemaTV, Inc. All Rights Reserved GoogleͷDIϥΠϒϥϦ Dagger Hiltͷ υΩϡϝϯτͷHilt Testing
PhilosophyΑΓ ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏ 30 • ҎԼͷॱ൪Ͱ͏ ◦ ຊͷΦϒδΣΫτ ◦ ϥΠϒϥϦ͕ఏڙ͢ΔFake ◦ Mock • (ύϑΥʔϚϯεͳͲͷཁ݅ʹΑΓม ΘΔɻ) ϝϦοτ https://dagger.dev/hilt/testing-philosophy.html ΑΓ -
AbemaTV, Inc. All Rights Reserved GoogleͷDIϥΠϒϥϦ Dagger Hiltͷ υΩϡϝϯτͷHilt Testing
PhilosophyΑΓ ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏ 30 • ҎԼͷॱ൪Ͱ͏ ◦ ຊͷΦϒδΣΫτ ◦ ϥΠϒϥϦ͕ఏڙ͢ΔFake ◦ Mock • (ύϑΥʔϚϯεͳͲͷཁ݅ʹΑΓม ΘΔɻ) ϝϦοτ • ຊͷΦϒδΣΫτຊͷΛΩϟον͢Δ https://dagger.dev/hilt/testing-philosophy.html ΑΓ -
AbemaTV, Inc. All Rights Reserved GoogleͷDIϥΠϒϥϦ Dagger Hiltͷ υΩϡϝϯτͷHilt Testing
PhilosophyΑΓ ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏ 30 • ҎԼͷॱ൪Ͱ͏ ◦ ຊͷΦϒδΣΫτ ◦ ϥΠϒϥϦ͕ఏڙ͢ΔFake ◦ Mock • (ύϑΥʔϚϯεͳͲͷཁ݅ʹΑΓม ΘΔɻ) ϝϦοτ • ຊͷΦϒδΣΫτຊͷΛΩϟον͢Δ • ಉ͡ΧόϨοδʹରͯ͠ɺগͳ͍ςετίʔυͰྑ͘ͳ Δ https://dagger.dev/hilt/testing-philosophy.html ΑΓ -
AbemaTV, Inc. All Rights Reserved GoogleͷDIϥΠϒϥϦ Dagger Hiltͷ υΩϡϝϯτͷHilt Testing
PhilosophyΑΓ ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏ 30 • ҎԼͷॱ൪Ͱ͏ ◦ ຊͷΦϒδΣΫτ ◦ ϥΠϒϥϦ͕ఏڙ͢ΔFake ◦ Mock • (ύϑΥʔϚϯεͳͲͷཁ݅ʹΑΓม ΘΔɻ) ϝϦοτ • ຊͷΦϒδΣΫτຊͷΛΩϟον͢Δ • ಉ͡ΧόϨοδʹରͯ͠ɺগͳ͍ςετίʔυͰྑ͘ͳ Δ • ςετ͕ࣦഊ͢Δͱ͖ຊͷΛर͍ͬͯΔՄೳੑ ͕ߴ͘ͳΔ https://dagger.dev/hilt/testing-philosophy.html ΑΓ -
AbemaTV, Inc. All Rights Reserved GoogleͷDIϥΠϒϥϦ Dagger Hiltͷ υΩϡϝϯτͷHilt Testing
PhilosophyΑΓ ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏ 30 • ҎԼͷॱ൪Ͱ͏ ◦ ຊͷΦϒδΣΫτ ◦ ϥΠϒϥϦ͕ఏڙ͢ΔFake ◦ Mock • (ύϑΥʔϚϯεͳͲͷཁ݅ʹΑΓม ΘΔɻ) ϝϦοτ • ຊͷΦϒδΣΫτຊͷΛΩϟον͢Δ • ಉ͡ΧόϨοδʹରͯ͠ɺগͳ͍ςετίʔυͰྑ͘ͳ Δ • ςετ͕ࣦഊ͢Δͱ͖ຊͷΛर͍ͬͯΔՄೳੑ ͕ߴ͘ͳΔ • Ϣʔβʔ͔Βͷ؍Ͱςετ͍͢͠ https://dagger.dev/hilt/testing-philosophy.html ΑΓ -
AbemaTV, Inc. All Rights Reserved ͱͱͷ࣮ͷ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 31 ※ʮFIFA ϫʔϧυΧοϓ
Χλʔϧ 2022ʯΛશ64ࢼ߹ແྉੜதܧ͢ΔʮABEMAʯ͕αοΧʔͷ ৽͍͠ࢹௌମݧΛଅਐ͢Δ৽ػೳΛൃදɺແྉͷʮݟಀ͠ϑϧϚον৴ʯʮϋΠϥΠτө૾ʯ ͳͲɺ11݄20ʢʣ։ນͱಉ࣌ʹఏڙ։࢝ https://www.cyberagent.co.jp/news/detail/id=28189 -
AbemaTV, Inc. All Rights Reserved ͱͱͷ࣮ͷ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 31 • ࠓճͷ࣮Ͱը໘ͷঢ়ଶ͚ͩͰɺ์ૹͷػɺ์ૹͷ
ࢹௌɺ͔͚ͬ࠶ੜͷࢹௌɺݟಀ͠৴ͷࢹௌ˞͕͋Γɺ ์ૹͷऴྃɺ։࢝ΛखಈͰςετ͢ΔʹࣗͰ൪Λฤ ͯ͠ɺ์ૹ࣌ؒ·ͰͬͨΓɺ์ૹऴྃΛͬͨΓ͢Δ ඞཁ͕͋Δɻ ※ʮFIFA ϫʔϧυΧοϓ Χλʔϧ 2022ʯΛશ64ࢼ߹ແྉੜதܧ͢ΔʮABEMAʯ͕αοΧʔͷ ৽͍͠ࢹௌମݧΛଅਐ͢Δ৽ػೳΛൃදɺແྉͷʮݟಀ͠ϑϧϚον৴ʯʮϋΠϥΠτө૾ʯ ͳͲɺ11݄20ʢʣ։ນͱಉ࣌ʹఏڙ։࢝ https://www.cyberagent.co.jp/news/detail/id=28189 -
AbemaTV, Inc. All Rights Reserved ͱͱͷ࣮ͷ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 31 • ࠓճͷ࣮Ͱը໘ͷঢ়ଶ͚ͩͰɺ์ૹͷػɺ์ૹͷ
ࢹௌɺ͔͚ͬ࠶ੜͷࢹௌɺݟಀ͠৴ͷࢹௌ˞͕͋Γɺ ์ૹͷऴྃɺ։࢝ΛखಈͰςετ͢ΔʹࣗͰ൪Λฤ ͯ͠ɺ์ૹ࣌ؒ·ͰͬͨΓɺ์ૹऴྃΛͬͨΓ͢Δ ඞཁ͕͋Δɻ • ViewModelɺUseCaseͳͲݸผʹࡉ͔͘ςετΛॻ͍͍ͯ ͯɺ࣮ࡍͷΛΩϟον͠ʹ͘͘ɺࡉ͔͍ϓϩύςΟ͕ ૿͑ΔͳͲͰςετ͕յΕͨΓվमΛೖΕΔࣄ͕ଟ͔ͬ ͨɻ ※ʮFIFA ϫʔϧυΧοϓ Χλʔϧ 2022ʯΛશ64ࢼ߹ແྉੜதܧ͢ΔʮABEMAʯ͕αοΧʔͷ ৽͍͠ࢹௌମݧΛଅਐ͢Δ৽ػೳΛൃදɺແྉͷʮݟಀ͠ϑϧϚον৴ʯʮϋΠϥΠτө૾ʯ ͳͲɺ11݄20ʢʣ։ນͱಉ࣌ʹఏڙ։࢝ https://www.cyberagent.co.jp/news/detail/id=28189 -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 32 Robolectric +
Dagger HiltͰςετΛ࣮͢Δ • Robolectric -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 32 Robolectric +
Dagger HiltͰςετΛ࣮͢Δ • Robolectric ◦ ͭ·Γ࣮ߦڥ࣮ػͰͳ͘JVM্Ͱಈ͔͢ςε τɻEspressoͱಉ͡ςετίʔυͰςετΛॻ͚Δɻ -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 32 Robolectric +
Dagger HiltͰςετΛ࣮͢Δ • Robolectric ◦ ͭ·Γ࣮ߦڥ࣮ػͰͳ͘JVM্Ͱಈ͔͢ςε τɻEspressoͱಉ͡ςετίʔυͰςετΛॻ͚Δɻ ◦ UIʹؔͯ͠ຊͷΦϒδΣΫτͰͳ͘ͳΔ͕ɺςε τͷ҆ఆੑΛ֬อ͢ΔͨΊ -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 32 Robolectric +
Dagger HiltͰςετΛ࣮͢Δ • Robolectric ◦ ͭ·Γ࣮ߦڥ࣮ػͰͳ͘JVM্Ͱಈ͔͢ςε τɻEspressoͱಉ͡ςετίʔυͰςετΛॻ͚Δɻ ◦ UIʹؔͯ͠ຊͷΦϒδΣΫτͰͳ͘ͳΔ͕ɺςε τͷ҆ఆੑΛ֬อ͢ΔͨΊ • Hilt -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 32 Robolectric +
Dagger HiltͰςετΛ࣮͢Δ • Robolectric ◦ ͭ·Γ࣮ߦڥ࣮ػͰͳ͘JVM্Ͱಈ͔͢ςε τɻEspressoͱಉ͡ςετίʔυͰςετΛॻ͚Δɻ ◦ UIʹؔͯ͠ຊͷΦϒδΣΫτͰͳ͘ͳΔ͕ɺςε τͷ҆ఆੑΛ֬อ͢ΔͨΊ • Hilt ◦ ΞϓϦͰAPI͚ͩFakeʹஔ͖͑Λߦ͏ -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 32 Robolectric +
Dagger HiltͰςετΛ࣮͢Δ • Robolectric ◦ ͭ·Γ࣮ߦڥ࣮ػͰͳ͘JVM্Ͱಈ͔͢ςε τɻEspressoͱಉ͡ςετίʔυͰςετΛॻ͚Δɻ ◦ UIʹؔͯ͠ຊͷΦϒδΣΫτͰͳ͘ͳΔ͕ɺςε τͷ҆ఆੑΛ֬อ͢ΔͨΊ • Hilt ◦ ΞϓϦͰAPI͚ͩFakeʹஔ͖͑Λߦ͏ ▪ Dagger HiltͷTestInstallIn()ΛͬͯAPI͚ͩஔ ͖͑Δɻ -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 32 Robolectric +
Dagger HiltͰςετΛ࣮͢Δ • Robolectric ◦ ͭ·Γ࣮ߦڥ࣮ػͰͳ͘JVM্Ͱಈ͔͢ςε τɻEspressoͱಉ͡ςετίʔυͰςετΛॻ͚Δɻ ◦ UIʹؔͯ͠ຊͷΦϒδΣΫτͰͳ͘ͳΔ͕ɺςε τͷ҆ఆੑΛ֬อ͢ΔͨΊ • Hilt ◦ ΞϓϦͰAPI͚ͩFakeʹஔ͖͑Λߦ͏ ▪ Dagger HiltͷTestInstallIn()ΛͬͯAPI͚ͩஔ ͖͑Δɻ ▪ ͜ΕʹΑΓ΄ͱΜͲͷ࣮͕ຊͷΦϒδΣΫ τͱͳΔ -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 33 ViewAPIͷϨεϙϯεͳͲʹґଘ͢Δςε τΛॻ͘ͱมߋʹऑ͘ͳΔͷͰʁ
ྫ͑λΠτϧͷViewͷIDॻ͖͑ͨΒશ෦ͷς ετॻ͖͢ͷʁ -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 33 ViewAPIͷϨεϙϯεͳͲʹґଘ͢Δςε τΛॻ͘ͱมߋʹऑ͘ͳΔͷͰʁ
ྫ͑λΠτϧͷViewͷIDॻ͖͑ͨΒશ෦ͷς ετॻ͖͢ͷʁ • → Robot PatternΛ͏ɻ͜Εςετ ͷ”what”ͱ”how”Λ͢Δ˞ -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 33 ViewAPIͷϨεϙϯεͳͲʹґଘ͢Δςε τΛॻ͘ͱมߋʹऑ͘ͳΔͷͰʁ
ྫ͑λΠτϧͷViewͷIDॻ͖͑ͨΒશ෦ͷς ετॻ͖͢ͷʁ • → Robot PatternΛ͏ɻ͜Εςετ ͷ”what”ͱ”how”Λ͢Δ˞ ※ https://jakewharton.com/testing-robots/ΑΓ -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 34 @Test fun
shouldPlayButtonVisibleWhenFinishingProgram() { robot { setupServer(NotProgramStartedPattern) launchScreen() // ൪ऴྃ·Ͱͭ(TestCoroutineSchedulerΛ͍͡Δ) waitForFinishingProgram() checkPlayButtonVisible() } } -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 34 @Test fun
shouldPlayButtonVisibleWhenFinishingProgram() { robot { setupServer(NotProgramStartedPattern) launchScreen() // ൪ऴྃ·Ͱͭ(TestCoroutineSchedulerΛ͍͡Δ) waitForFinishingProgram() checkPlayButtonVisible() } } robot{}Ͱғͬͯɺςετͷ”how” robotʹͬͯΒ͏ -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 34 @Test fun
shouldPlayButtonVisibleWhenFinishingProgram() { robot { setupServer(NotProgramStartedPattern) launchScreen() // ൪ऴྃ·Ͱͭ(TestCoroutineSchedulerΛ͍͡Δ) waitForFinishingProgram() checkPlayButtonVisible() } } APIηοτΞοϓ͋Δ͕ɺϨε ϙϯεΛࢦఆͨ͠Γ͠ͳ͍ (RobotʹͬͯΒ͏) robot{}Ͱғͬͯɺςετͷ”how” robotʹͬͯΒ͏ -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 34 @Test fun
shouldPlayButtonVisibleWhenFinishingProgram() { robot { setupServer(NotProgramStartedPattern) launchScreen() // ൪ऴྃ·Ͱͭ(TestCoroutineSchedulerΛ͍͡Δ) waitForFinishingProgram() checkPlayButtonVisible() } } APIηοτΞοϓ͋Δ͕ɺϨε ϙϯεΛࢦఆͨ͠Γ͠ͳ͍ (RobotʹͬͯΒ͏) ViewͷνΣοΫ͋Δ͕IDΛݟͨ Γ͠ͳ͍ (RobotʹͬͯΒ͏) robot{}Ͱғͬͯɺςετͷ”how” robotʹͬͯΒ͏ -
AbemaTV, Inc. All Rights Reserved Robotͷ࣮ʁ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 35 @Inject lateinit
val robot: Robot @Test fun test() { robot { hoge() } } class Robot { operator fun invoke(block: Robot.() -> Unit) { runTest{ block() } } fun hoge() {...} } -
AbemaTV, Inc. All Rights Reserved Ͳ͏͔ͨ͠ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 36 @Test fun
shouldPlayButtonVisibleWhenFinishingProgram() { robot { setupServer(NotProgramStartedPattern) launchScreen() // ൪ऴྃ·Ͱͭ waitForFinishingProgram() checkPlayButtonVisible() } } ςετͷ ”What = ԿΛ͢Δ͔”ͱ”How = Ͳ͏ͬͯΔ͔” Λ͢Δͷ͕Robot Patternɻ ςετΞϓϦͱಉ͡Α͏ʹઃܭ͢Δɻ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 37 • τϨʔυΦϑ
◦ ςετͰ͕͋Δͱ͖ʹݪҼ͕͔Δ·Ͱʹ͕͔͔࣌ؒΔɻ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 37 • τϨʔυΦϑ
◦ ςετͰ͕͋Δͱ͖ʹݪҼ͕͔Δ·Ͱʹ͕͔͔࣌ؒΔɻ ▪ → ׂͱࡉ͔Ίʹϝιουͷݺͼग़͠ͱ͔ͷϩάΛೖΕΔɻ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 37 • τϨʔυΦϑ
◦ ςετͰ͕͋Δͱ͖ʹݪҼ͕͔Δ·Ͱʹ͕͔͔࣌ؒΔɻ ▪ → ׂͱࡉ͔Ίʹϝιουͷݺͼग़͠ͱ͔ͷϩάΛೖΕΔɻ • → ςετͰϩάϥΠϒϥϦ͕println()ʹϩάΛग़͢Α͏ʹTest RuleΛ࡞ͬͯͦΕΛ͏ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 37 • τϨʔυΦϑ
◦ ςετͰ͕͋Δͱ͖ʹݪҼ͕͔Δ·Ͱʹ͕͔͔࣌ؒΔɻ ▪ → ׂͱࡉ͔Ίʹϝιουͷݺͼग़͠ͱ͔ͷϩάΛೖΕΔɻ • → ςετͰϩάϥΠϒϥϦ͕println()ʹϩάΛग़͢Α͏ʹTest RuleΛ࡞ͬͯͦΕΛ͏ • → ύϑΥʔϚϯε؍ͰTimberCompat.d{} ͷΑ͏ͳܗͷؔΛ༻ҙͯ͠ɺຊ൪ͰϥϜμΛ࣮ߦ͠ͳ͍͜ͱͰɺ toString()Λຊ൪Ͱ࣮ߦ͠ͳ͍Α͏ʹ͢Δɻ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 37 • τϨʔυΦϑ
◦ ςετͰ͕͋Δͱ͖ʹݪҼ͕͔Δ·Ͱʹ͕͔͔࣌ؒΔɻ ▪ → ׂͱࡉ͔Ίʹϝιουͷݺͼग़͠ͱ͔ͷϩάΛೖΕΔɻ • → ςετͰϩάϥΠϒϥϦ͕println()ʹϩάΛग़͢Α͏ʹTest RuleΛ࡞ͬͯͦΕΛ͏ • → ύϑΥʔϚϯε؍ͰTimberCompat.d{} ͷΑ͏ͳܗͷؔΛ༻ҙͯ͠ɺຊ൪ͰϥϜμΛ࣮ߦ͠ͳ͍͜ͱͰɺ toString()Λຊ൪Ͱ࣮ߦ͠ͳ͍Α͏ʹ͢Δɻ ◦ Robolectricͩͱɺը໘ݟΕͳ͍ͷͰɺ͠ςετಈ͍ͯɺݟ͑ͳ͍ͷͰಈ͍͍ͯΔͷ͔Α͔͘Βͳ͍ɻෆ҆ɻ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 37 • τϨʔυΦϑ
◦ ςετͰ͕͋Δͱ͖ʹݪҼ͕͔Δ·Ͱʹ͕͔͔࣌ؒΔɻ ▪ → ׂͱࡉ͔Ίʹϝιουͷݺͼग़͠ͱ͔ͷϩάΛೖΕΔɻ • → ςετͰϩάϥΠϒϥϦ͕println()ʹϩάΛग़͢Α͏ʹTest RuleΛ࡞ͬͯͦΕΛ͏ • → ύϑΥʔϚϯε؍ͰTimberCompat.d{} ͷΑ͏ͳܗͷؔΛ༻ҙͯ͠ɺຊ൪ͰϥϜμΛ࣮ߦ͠ͳ͍͜ͱͰɺ toString()Λຊ൪Ͱ࣮ߦ͠ͳ͍Α͏ʹ͢Δɻ ◦ Robolectricͩͱɺը໘ݟΕͳ͍ͷͰɺ͠ςετಈ͍ͯɺݟ͑ͳ͍ͷͰಈ͍͍ͯΔͷ͔Α͔͘Βͳ͍ɻෆ҆ɻ ▪ → Roborazziͱ͍͏ՄࢹԽϥΠϒϥϦΛ࠷ۙ࡞ͬͨͷͰͬͯݟ͍ͯͩ͘͞ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 37 • τϨʔυΦϑ
◦ ςετͰ͕͋Δͱ͖ʹݪҼ͕͔Δ·Ͱʹ͕͔͔࣌ؒΔɻ ▪ → ׂͱࡉ͔Ίʹϝιουͷݺͼग़͠ͱ͔ͷϩάΛೖΕΔɻ • → ςετͰϩάϥΠϒϥϦ͕println()ʹϩάΛग़͢Α͏ʹTest RuleΛ࡞ͬͯͦΕΛ͏ • → ύϑΥʔϚϯε؍ͰTimberCompat.d{} ͷΑ͏ͳܗͷؔΛ༻ҙͯ͠ɺຊ൪ͰϥϜμΛ࣮ߦ͠ͳ͍͜ͱͰɺ toString()Λຊ൪Ͱ࣮ߦ͠ͳ͍Α͏ʹ͢Δɻ ◦ Robolectricͩͱɺը໘ݟΕͳ͍ͷͰɺ͠ςετಈ͍ͯɺݟ͑ͳ͍ͷͰಈ͍͍ͯΔͷ͔Α͔͘Βͳ͍ɻෆ҆ɻ ▪ → Roborazziͱ͍͏ՄࢹԽϥΠϒϥϦΛ࠷ۙ࡞ͬͨͷͰͬͯݟ͍ͯͩ͘͞ ◦ RobolectricActivityؒͷҠಈςετͰ͖ͳ͍ɻ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 37 • τϨʔυΦϑ
◦ ςετͰ͕͋Δͱ͖ʹݪҼ͕͔Δ·Ͱʹ͕͔͔࣌ؒΔɻ ▪ → ׂͱࡉ͔Ίʹϝιουͷݺͼग़͠ͱ͔ͷϩάΛೖΕΔɻ • → ςετͰϩάϥΠϒϥϦ͕println()ʹϩάΛग़͢Α͏ʹTest RuleΛ࡞ͬͯͦΕΛ͏ • → ύϑΥʔϚϯε؍ͰTimberCompat.d{} ͷΑ͏ͳܗͷؔΛ༻ҙͯ͠ɺຊ൪ͰϥϜμΛ࣮ߦ͠ͳ͍͜ͱͰɺ toString()Λຊ൪Ͱ࣮ߦ͠ͳ͍Α͏ʹ͢Δɻ ◦ Robolectricͩͱɺը໘ݟΕͳ͍ͷͰɺ͠ςετಈ͍ͯɺݟ͑ͳ͍ͷͰಈ͍͍ͯΔͷ͔Α͔͘Βͳ͍ɻෆ҆ɻ ▪ → Roborazziͱ͍͏ՄࢹԽϥΠϒϥϦΛ࠷ۙ࡞ͬͨͷͰͬͯݟ͍ͯͩ͘͞ ◦ RobolectricActivityؒͷҠಈςετͰ͖ͳ͍ɻ ▪ FragmentͳΒOK -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 37 • τϨʔυΦϑ
◦ ςετͰ͕͋Δͱ͖ʹݪҼ͕͔Δ·Ͱʹ͕͔͔࣌ؒΔɻ ▪ → ׂͱࡉ͔Ίʹϝιουͷݺͼग़͠ͱ͔ͷϩάΛೖΕΔɻ • → ςετͰϩάϥΠϒϥϦ͕println()ʹϩάΛग़͢Α͏ʹTest RuleΛ࡞ͬͯͦΕΛ͏ • → ύϑΥʔϚϯε؍ͰTimberCompat.d{} ͷΑ͏ͳܗͷؔΛ༻ҙͯ͠ɺຊ൪ͰϥϜμΛ࣮ߦ͠ͳ͍͜ͱͰɺ toString()Λຊ൪Ͱ࣮ߦ͠ͳ͍Α͏ʹ͢Δɻ ◦ Robolectricͩͱɺը໘ݟΕͳ͍ͷͰɺ͠ςετಈ͍ͯɺݟ͑ͳ͍ͷͰಈ͍͍ͯΔͷ͔Α͔͘Βͳ͍ɻෆ҆ɻ ▪ → Roborazziͱ͍͏ՄࢹԽϥΠϒϥϦΛ࠷ۙ࡞ͬͨͷͰͬͯݟ͍ͯͩ͘͞ ◦ RobolectricActivityؒͷҠಈςετͰ͖ͳ͍ɻ ▪ FragmentͳΒOK • ସखஈ -
AbemaTV, Inc. All Rights Reserved τϨʔυΦϑʁସखஈʁ “ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏”ΛͲ͏͔ͬͨ 37 • τϨʔυΦϑ
◦ ςετͰ͕͋Δͱ͖ʹݪҼ͕͔Δ·Ͱʹ͕͔͔࣌ؒΔɻ ▪ → ׂͱࡉ͔Ίʹϝιουͷݺͼग़͠ͱ͔ͷϩάΛೖΕΔɻ • → ςετͰϩάϥΠϒϥϦ͕println()ʹϩάΛग़͢Α͏ʹTest RuleΛ࡞ͬͯͦΕΛ͏ • → ύϑΥʔϚϯε؍ͰTimberCompat.d{} ͷΑ͏ͳܗͷؔΛ༻ҙͯ͠ɺຊ൪ͰϥϜμΛ࣮ߦ͠ͳ͍͜ͱͰɺ toString()Λຊ൪Ͱ࣮ߦ͠ͳ͍Α͏ʹ͢Δɻ ◦ Robolectricͩͱɺը໘ݟΕͳ͍ͷͰɺ͠ςετಈ͍ͯɺݟ͑ͳ͍ͷͰಈ͍͍ͯΔͷ͔Α͔͘Βͳ͍ɻෆ҆ɻ ▪ → Roborazziͱ͍͏ՄࢹԽϥΠϒϥϦΛ࠷ۙ࡞ͬͨͷͰͬͯݟ͍ͯͩ͘͞ ◦ RobolectricActivityؒͷҠಈςετͰ͖ͳ͍ɻ ▪ FragmentͳΒOK • ସखஈ ◦ ࠓճΞϓϦΛͳΔ͘౷߹ͨ͠ςετΛߦ͍ͬͯͨɻཧతʹE2E͍͖ͬͯ͘Ͱ͋Δ͕Ͳ͏͍͔ͯ͘͠ɻ -
AbemaTV, Inc. All Rights Reserved ·ͱΊ 38 • ҎԼͷݪଇΛར༻ͯ͠վળ͠ɺৼΓฦΓΛ͍͖ͯ͠·ͨ͠ɻ ◦
Single Source of Truth -
AbemaTV, Inc. All Rights Reserved ·ͱΊ 38 • ҎԼͷݪଇΛར༻ͯ͠վળ͠ɺৼΓฦΓΛ͍͖ͯ͠·ͨ͠ɻ ◦
Single Source of Truth ◦ Unidirectional Data Flow -
AbemaTV, Inc. All Rights Reserved ·ͱΊ 38 • ҎԼͷݪଇΛར༻ͯ͠վળ͠ɺৼΓฦΓΛ͍͖ͯ͠·ͨ͠ɻ ◦
Single Source of Truth ◦ Unidirectional Data Flow ◦ ViewModel͔ΒUIʹΠϕϯτΛૹΒͳ͍ -
AbemaTV, Inc. All Rights Reserved ·ͱΊ 38 • ҎԼͷݪଇΛར༻ͯ͠վળ͠ɺৼΓฦΓΛ͍͖ͯ͠·ͨ͠ɻ ◦
Single Source of Truth ◦ Unidirectional Data Flow ◦ ViewModel͔ΒUIʹΠϕϯτΛૹΒͳ͍ ◦ ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏ -
AbemaTV, Inc. All Rights Reserved ·ͱΊ 38 • ҎԼͷݪଇΛར༻ͯ͠վળ͠ɺৼΓฦΓΛ͍͖ͯ͠·ͨ͠ɻ ◦
Single Source of Truth ◦ Unidirectional Data Flow ◦ ViewModel͔ΒUIʹΠϕϯτΛૹΒͳ͍ ◦ ςετͰͰ͖Δ͚ͩຊͷΦϒδΣΫτΛ͏ • ͜ͷΑ͏ͳ͞·͟·ͳऔΓΈʹɺਖ਼ղͳ͍औΓΈͩͱࢥ͍ͬͯΔΜͰ͕͢ɺΞτ ϓοτͯ͠ɺؒҧ͍ͬͯͨΓɺࢹͱͯ͠ൈ͚͍ͯΔͱ͜ΖͳͲ͕͋ΕɺϑΟʔυόοΫͳ Ͳ͔Βؾ͖ͮΛಘͨΓ͠ͳ͕Βվળ͍͚ͯ͠Δͱ͍͍ͳͱࢥ͍ͬͯ·͢ɻ -
AbemaTV, Inc. All Rights Reserved Special thanks 39 • ։ൃɾϨϏϡʔΛҰॹʹͯ͘͠Εͨ
◦ @fuji_kinaga ͞Μ ◦ ଞABEMA NativeνʔϜͷօ͞Μ