From dffd037383fd83471c7850a8674a5838758ce134 Mon Sep 17 00:00:00 2001 From: Hiroyuki Kusu Date: Sun, 24 May 2026 20:42:07 +0900 Subject: [PATCH 1/2] Rename ViewStore render and handle APIs --- README.md | 20 +++---- .../2026-04-30-viewstore-compose-naming.md | 10 ++-- .../notes/2026-04-23-store-start-policy.md | 2 +- .../github/komakt/koma/compose/ViewStore.kt | 28 ++++++++-- .../komakt/koma/compose/ViewStoreJvmTest.kt | 56 ++++++++++++++++--- 5 files changed, 87 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index ca31c3cb..fc2f32ae 100644 --- a/README.md +++ b/README.md @@ -757,37 +757,37 @@ Text( ) ``` -If there are multiple *States*, use the `.render()` method for the target *State*. +If there are multiple *States*, use the `.renderState()` method for the target *State*. ```kt -viewStore.render { +viewStore.renderState { Text( text = state.count.toString(), ) } ``` -When drawing the UI, if it does not match the target *State*, the `.render()` will not be executed. +When drawing the UI, if it does not match the target *State*, the `.renderState()` will not be executed. Therefore, you can define components for each *State* side by side. ```kt -viewStore.render { +viewStore.renderState { Text( text = "loading..", ) } -viewStore.render { +viewStore.renderState { Text( text = state.count.toString(), ) } ``` -If you use lower components in the `render()` block, pass its instance. +If you use lower components in the `renderState()` block, pass its instance. ```kt -viewStore.render { +viewStore.renderState { YourComposable( viewStore = this, // ViewStore instance for CounterState.Main ) @@ -822,10 +822,10 @@ Button( ### Handling Events -Use ViewStore's `.handle()` with the target *Event*. +Use ViewStore's `.collectEvent()` with the target *Event*. ```kt -viewStore.handle { event -> +viewStore.collectEvent { event -> // do something.. } ``` @@ -833,7 +833,7 @@ viewStore.handle { event -> In the above example, you can also subscribe to the parent *Event* type. ```kt -viewStore.handle { event -> +viewStore.collectEvent { event -> when (event) { is CounterEvent.ShowToast -> // do something.. is CounterEvent.GoBack -> // do something.. diff --git a/doc/internal/adr/2026-04-30-viewstore-compose-naming.md b/doc/internal/adr/2026-04-30-viewstore-compose-naming.md index fcaa6d76..7dec851b 100644 --- a/doc/internal/adr/2026-04-30-viewstore-compose-naming.md +++ b/doc/internal/adr/2026-04-30-viewstore-compose-naming.md @@ -4,23 +4,23 @@ ## 背景 -`ViewStore.render` / `ViewStore.handle` は `@Composable` であり、Compose の naming guideline にそのまま寄せるなら、`Unit` を返す public composable として PascalCase の名前にしたくなる。 +`ViewStore.renderState` / `ViewStore.collectEvent` は `@Composable` であり、Compose の naming guideline にそのまま寄せるなら、`Unit` を返す public composable として PascalCase の名前にしたくなる。 このため、次の 2 方向を検討した。 - トップレベル関数として `StateContent(viewStore) {}` / `EventHandler(viewStore) {}` - `ViewStore` のメンバ関数として `viewStore.StateContent {}` / `viewStore.EventHandler {}` -ただし、どちらも現在の `viewStore.render {}` / `viewStore.handle {}` が持つ DSL としての自然さを崩す懸念があった。 +ただし、どちらも現在の `viewStore.renderState {}` / `viewStore.collectEvent {}` が持つ DSL としての自然さを崩す懸念があった。 ## 決定 -`ViewStore.render` / `ViewStore.handle` を PascalCase の別 API に置き換える案は採用しない。 +`ViewStore.renderState` / `ViewStore.collectEvent` を PascalCase の別 API に置き換える案は採用しない。 現時点では、既存の lowerCamelCase API を維持する。 -- `viewStore.render<...> { ... }` -- `viewStore.handle<...> { ... }` +- `viewStore.renderState<...> { ... }` +- `viewStore.collectEvent<...> { ... }` ## 補足 diff --git a/doc/internal/notes/2026-04-23-store-start-policy.md b/doc/internal/notes/2026-04-23-store-start-policy.md index 58caa0a9..68ef4132 100644 --- a/doc/internal/notes/2026-04-23-store-start-policy.md +++ b/doc/internal/notes/2026-04-23-store-start-policy.md @@ -52,7 +52,7 @@ fun startPolicy(policy: StoreStartPolicy) - 未採用候補として `EAGER` も考えられる。これは「`dispatch()` や `state` の collect を待たず、Store 作成直後に start する」という意味になる。v1 では見送るのがよい。`attachObserver()` が start 前のみ許可という現行前提と衝突しやすい。 - `ON_FIRST_DISPATCH` では、`state` を collect しても start しない。その場合でも `StateFlow` としては current snapshot を読めるので、UI が「現在値の監視」と「副作用の開始」を分離しやすくなる。 - start 直後に `enter { event(...) }` のような one-shot event を出したい場合、現状の default では `state` の collect が先に start trigger になり、あとから `event` を購読した側が初回 event を見逃しうる。 -- この問題は Compose の `rememberViewStore()` でも起こりうる。`rememberViewStore()` は内部で `store.state.collectAsState()` を行う一方、event の collect は `ViewStore.handle()` 側の `LaunchedEffect` で始まるため、同じ画面内で両方を書いていても event collector が start 前に間に合う保証はない。 +- この問題は Compose の `rememberViewStore()` でも起こりうる。`rememberViewStore()` は内部で `store.state.collectAsState()` を行う一方、event の collect は `ViewStore.collectEvent()` 側の `LaunchedEffect` で始まるため、同じ画面内で両方を書いていても event collector が start 前に間に合う保証はない。 - この問題に対しては start policy が有効な回避策になりうる。`ON_FIRST_DISPATCH` なら `state` / `event` の購読を張ったあとに明示的な最初の `dispatch()` で start でき、`MANUAL` なら購読を張ったあとに `start()` を呼ぶ順序をさらに明示しやすい。 - ただし start policy が解決するのは「購読前に start しない」ことまでであり、`Store.event` 自体の replay semantics は変えない。start 後に購読した側へ過去 event を再配送するわけではない。 - `MANUAL` で start 前に `dispatch()` された場合は、暗黙 start や silently ignore ではなく、例外で失敗させる方がバグを早く見つけやすい。 diff --git a/koma-compose/src/commonMain/kotlin/io/github/komakt/koma/compose/ViewStore.kt b/koma-compose/src/commonMain/kotlin/io/github/komakt/koma/compose/ViewStore.kt index 36525970..c375bfaa 100644 --- a/koma-compose/src/commonMain/kotlin/io/github/komakt/koma/compose/ViewStore.kt +++ b/koma-compose/src/commonMain/kotlin/io/github/komakt/koma/compose/ViewStore.kt @@ -63,13 +63,22 @@ class ViewStore internal constructor( */ @Suppress("ComposableNaming") @Composable - inline fun render(block: @Composable ViewStore.() -> Unit) { + inline fun renderState(block: @Composable ViewStore.() -> Unit) { if (state is S2) { @Suppress("UNCHECKED_CAST") block(this as ViewStore) } } + @Deprecated( + message = "Use renderState instead.", + replaceWith = ReplaceWith("renderState(block)"), + level = DeprecationLevel.WARNING, + ) + @Suppress("ComposableNaming") + @Composable + inline fun render(block: @Composable ViewStore.() -> Unit) = renderState(block) + /** * Collects only events of type [E2] while this composable is in the composition. * @@ -80,7 +89,7 @@ class ViewStore internal constructor( */ @Suppress("ComposableNaming") @Composable - inline fun handle(noinline block: ViewStore.(event: E2) -> Unit) { + inline fun collectEvent(noinline block: ViewStore.(event: E2) -> Unit) { val currentViewStore = rememberUpdatedState(this) val currentBlock = rememberUpdatedState(block) LaunchedEffect(eventFlow) { @@ -89,15 +98,24 @@ class ViewStore internal constructor( } } } + + @Deprecated( + message = "Use collectEvent instead.", + replaceWith = ReplaceWith("collectEvent(block)"), + level = DeprecationLevel.WARNING, + ) + @Suppress("ComposableNaming") + @Composable + inline fun handle(noinline block: ViewStore.(event: E2) -> Unit) = collectEvent(block) } /** * Remembers a [Store], collects its state as Compose state, and exposes it through a [ViewStore]. * * Collecting [Store.state] starts the Store immediately. - * Because [ViewStore.handle] starts collecting later from a [LaunchedEffect], startup events such - * as events emitted from an initial `enter {}` handler may be emitted before handlers in the same - * composition begin observing them. + * Because [ViewStore.collectEvent] starts collecting later from a [LaunchedEffect], startup events + * such as events emitted from an initial `enter {}` handler may be emitted before handlers in the + * same composition begin observing them. * * The [store] lambda is used only when a new remembered Store must be created for [key]. * For a given remembered Store instance, this function returns the same [ViewStore] instance across diff --git a/koma-compose/src/jvmTest/kotlin/io/github/komakt/koma/compose/ViewStoreJvmTest.kt b/koma-compose/src/jvmTest/kotlin/io/github/komakt/koma/compose/ViewStoreJvmTest.kt index c8d06527..cd60aaae 100644 --- a/koma-compose/src/jvmTest/kotlin/io/github/komakt/koma/compose/ViewStoreJvmTest.kt +++ b/koma-compose/src/jvmTest/kotlin/io/github/komakt/koma/compose/ViewStoreJvmTest.kt @@ -32,18 +32,18 @@ class ViewStoreJvmTest { private val testDispatcher = UnconfinedTestDispatcher() @Test - fun render_callsBlockOnlyForMatchingState() = runTest(testDispatcher) { + fun renderState_callsBlockOnlyForMatchingState() = runTest(testDispatcher) { val renderedValues = mutableListOf() withComposition( content = { ViewStore(state = UiState.Ready(10)) - .render { + .renderState { renderedValues += state.value } ViewStore(state = UiState.Loading) - .render { + .renderState { renderedValues += state.value } }, @@ -53,7 +53,7 @@ class ViewStoreJvmTest { } @Test - fun handle_collectsOnlySpecifiedEventType() = runTest(testDispatcher) { + fun collectEvent_collectsOnlySpecifiedEventType() = runTest(testDispatcher) { val events = MutableSharedFlow(extraBufferCapacity = 4) val handled = mutableListOf() @@ -62,7 +62,7 @@ class ViewStoreJvmTest { ViewStore( state = UiState.Ready(0), eventFlow = events, - ).handle { event -> + ).collectEvent { event -> handled += event } }, @@ -76,7 +76,7 @@ class ViewStoreJvmTest { } @Test - fun handle_usesLatestViewStoreAndLambdaAfterRecomposition() = runTest(testDispatcher) { + fun collectEvent_usesLatestViewStoreAndLambdaAfterRecomposition() = runTest(testDispatcher) { val events = MutableSharedFlow(extraBufferCapacity = 4) val handled = mutableListOf() var label = "initial" @@ -99,7 +99,7 @@ class ViewStoreJvmTest { ViewStore( state = viewState, eventFlow = events, - ).handle { event -> + ).collectEvent { event -> handled += "${(state as UiState.Ready).value}:$label:${event.value}" } } @@ -111,7 +111,7 @@ class ViewStoreJvmTest { ViewStore( state = viewState, eventFlow = events, - ).handle { event -> + ).collectEvent { event -> handled += "${(state as UiState.Ready).value}:$label:${event.value}" } } @@ -129,6 +129,46 @@ class ViewStoreJvmTest { assertEquals(listOf("2:updated:42"), handled) } + @Suppress("DEPRECATION") + @Test + fun render_delegatesToRenderState() = runTest(testDispatcher) { + val renderedValues = mutableListOf() + + withComposition( + content = { + ViewStore(state = UiState.Ready(7)) + .render { + renderedValues += state.value + } + }, + ) + + assertEquals(listOf(7), renderedValues) + } + + @Suppress("DEPRECATION") + @Test + fun handle_delegatesToCollectEvent() = runTest(testDispatcher) { + val events = MutableSharedFlow(extraBufferCapacity = 4) + val handled = mutableListOf() + + withComposition( + content = { + ViewStore( + state = UiState.Ready(0), + eventFlow = events, + ).handle { event -> + handled += event + } + }, + afterSetContent = { + assertTrue(events.tryEmit(UiEvent.ValueChanged(99))) + }, + ) + + assertEquals(listOf(UiEvent.ValueChanged(99)), handled) + } + @Test fun rememberViewStore_providesCurrentStateAndDispatchesAction() = runTest(testDispatcher) { val store = TestStore(UiState.Ready(1)) From b4f61ef9fd36d30744a51007a839c8ac0a70fedc Mon Sep 17 00:00:00 2001 From: Hiroyuki Kusu Date: Mon, 25 May 2026 13:32:53 +0900 Subject: [PATCH 2/2] Rename --- README.md | 20 ++++++++-------- .../2026-04-30-viewstore-compose-naming.md | 17 ++++++++----- .../notes/2026-04-23-store-start-policy.md | 2 +- .../github/komakt/koma/compose/ViewStore.kt | 20 ++++++++-------- .../komakt/koma/compose/ViewStoreJvmTest.kt | 24 +++++++++---------- 5 files changed, 44 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index fc2f32ae..d17426a0 100644 --- a/README.md +++ b/README.md @@ -757,37 +757,37 @@ Text( ) ``` -If there are multiple *States*, use the `.renderState()` method for the target *State*. +If there are multiple *States*, use the `.stateContent()` method for the target *State*. ```kt -viewStore.renderState { +viewStore.stateContent { Text( text = state.count.toString(), ) } ``` -When drawing the UI, if it does not match the target *State*, the `.renderState()` will not be executed. +When drawing the UI, if it does not match the target *State*, the `.stateContent()` will not be executed. Therefore, you can define components for each *State* side by side. ```kt -viewStore.renderState { +viewStore.stateContent { Text( text = "loading..", ) } -viewStore.renderState { +viewStore.stateContent { Text( text = state.count.toString(), ) } ``` -If you use lower components in the `renderState()` block, pass its instance. +If you use lower components in the `stateContent()` block, pass its instance. ```kt -viewStore.renderState { +viewStore.stateContent { YourComposable( viewStore = this, // ViewStore instance for CounterState.Main ) @@ -822,10 +822,10 @@ Button( ### Handling Events -Use ViewStore's `.collectEvent()` with the target *Event*. +Use ViewStore's `.eventEffect()` with the target *Event*. ```kt -viewStore.collectEvent { event -> +viewStore.eventEffect { event -> // do something.. } ``` @@ -833,7 +833,7 @@ viewStore.collectEvent { event -> In the above example, you can also subscribe to the parent *Event* type. ```kt -viewStore.collectEvent { event -> +viewStore.eventEffect { event -> when (event) { is CounterEvent.ShowToast -> // do something.. is CounterEvent.GoBack -> // do something.. diff --git a/doc/internal/adr/2026-04-30-viewstore-compose-naming.md b/doc/internal/adr/2026-04-30-viewstore-compose-naming.md index 7dec851b..c3e7bb24 100644 --- a/doc/internal/adr/2026-04-30-viewstore-compose-naming.md +++ b/doc/internal/adr/2026-04-30-viewstore-compose-naming.md @@ -1,26 +1,26 @@ # `ViewStore.render` / `handle` の PascalCase 置き換えは採用しない -- 更新日: 2026-04-30 +- 更新日: 2026-05-25 ## 背景 -`ViewStore.renderState` / `ViewStore.collectEvent` は `@Composable` であり、Compose の naming guideline にそのまま寄せるなら、`Unit` を返す public composable として PascalCase の名前にしたくなる。 +`ViewStore.render` / `ViewStore.handle` は `@Composable` であり、Compose の naming guideline にそのまま寄せるなら、`Unit` を返す public composable として PascalCase の名前にしたくなる。 このため、次の 2 方向を検討した。 - トップレベル関数として `StateContent(viewStore) {}` / `EventHandler(viewStore) {}` - `ViewStore` のメンバ関数として `viewStore.StateContent {}` / `viewStore.EventHandler {}` -ただし、どちらも現在の `viewStore.renderState {}` / `viewStore.collectEvent {}` が持つ DSL としての自然さを崩す懸念があった。 +ただし、どちらも現在の `viewStore.render {}` / `viewStore.handle {}` が持つ DSL としての自然さを崩す懸念があった。 ## 決定 -`ViewStore.renderState` / `ViewStore.collectEvent` を PascalCase の別 API に置き換える案は採用しない。 +`ViewStore.render` / `ViewStore.handle` を PascalCase の別 API に置き換える案は採用しない。 現時点では、既存の lowerCamelCase API を維持する。 -- `viewStore.renderState<...> { ... }` -- `viewStore.collectEvent<...> { ... }` +- `viewStore.render<...> { ... }` +- `viewStore.handle<...> { ... }` ## 補足 @@ -29,3 +29,8 @@ - そのため今回は「Compose guideline への整合」より、「`ViewStore` DSL としての自然さ」を優先する。 - 既存 API には `@Suppress("ComposableNaming")` が必要だが、このコストは上記の不自然さを受け入れるより小さいと判断する。 - 将来、トップレベルでもメンバでもない、より自然な API 形が見つかった場合はあらためて検討してよい。 + +## 2026-05-25 追記 + +その後、API 名は `render` / `handle` から `stateContent` / `eventEffect` へリネームされた。 +この rename により、API の意味は Compose 文脈により沿うようになったが、member composable を PascalCase にするかという論点自体は変わっていない。 diff --git a/doc/internal/notes/2026-04-23-store-start-policy.md b/doc/internal/notes/2026-04-23-store-start-policy.md index 68ef4132..d4355a91 100644 --- a/doc/internal/notes/2026-04-23-store-start-policy.md +++ b/doc/internal/notes/2026-04-23-store-start-policy.md @@ -52,7 +52,7 @@ fun startPolicy(policy: StoreStartPolicy) - 未採用候補として `EAGER` も考えられる。これは「`dispatch()` や `state` の collect を待たず、Store 作成直後に start する」という意味になる。v1 では見送るのがよい。`attachObserver()` が start 前のみ許可という現行前提と衝突しやすい。 - `ON_FIRST_DISPATCH` では、`state` を collect しても start しない。その場合でも `StateFlow` としては current snapshot を読めるので、UI が「現在値の監視」と「副作用の開始」を分離しやすくなる。 - start 直後に `enter { event(...) }` のような one-shot event を出したい場合、現状の default では `state` の collect が先に start trigger になり、あとから `event` を購読した側が初回 event を見逃しうる。 -- この問題は Compose の `rememberViewStore()` でも起こりうる。`rememberViewStore()` は内部で `store.state.collectAsState()` を行う一方、event の collect は `ViewStore.collectEvent()` 側の `LaunchedEffect` で始まるため、同じ画面内で両方を書いていても event collector が start 前に間に合う保証はない。 +- この問題は Compose の `rememberViewStore()` でも起こりうる。`rememberViewStore()` は内部で `store.state.collectAsState()` を行う一方、event の collect は `ViewStore.eventEffect()` 側の `LaunchedEffect` で始まるため、同じ画面内で両方を書いていても event collector が start 前に間に合う保証はない。 - この問題に対しては start policy が有効な回避策になりうる。`ON_FIRST_DISPATCH` なら `state` / `event` の購読を張ったあとに明示的な最初の `dispatch()` で start でき、`MANUAL` なら購読を張ったあとに `start()` を呼ぶ順序をさらに明示しやすい。 - ただし start policy が解決するのは「購読前に start しない」ことまでであり、`Store.event` 自体の replay semantics は変えない。start 後に購読した側へ過去 event を再配送するわけではない。 - `MANUAL` で start 前に `dispatch()` された場合は、暗黙 start や silently ignore ではなく、例外で失敗させる方がバグを早く見つけやすい。 diff --git a/koma-compose/src/commonMain/kotlin/io/github/komakt/koma/compose/ViewStore.kt b/koma-compose/src/commonMain/kotlin/io/github/komakt/koma/compose/ViewStore.kt index c375bfaa..ca709e62 100644 --- a/koma-compose/src/commonMain/kotlin/io/github/komakt/koma/compose/ViewStore.kt +++ b/koma-compose/src/commonMain/kotlin/io/github/komakt/koma/compose/ViewStore.kt @@ -59,11 +59,11 @@ class ViewStore internal constructor( * * Inside [block], this [ViewStore] is narrowed to [S2]. * - * @param block Composable function to render the narrowed state + * @param block Composable function to render content for the narrowed state */ @Suppress("ComposableNaming") @Composable - inline fun renderState(block: @Composable ViewStore.() -> Unit) { + inline fun stateContent(block: @Composable ViewStore.() -> Unit) { if (state is S2) { @Suppress("UNCHECKED_CAST") block(this as ViewStore) @@ -71,13 +71,13 @@ class ViewStore internal constructor( } @Deprecated( - message = "Use renderState instead.", - replaceWith = ReplaceWith("renderState(block)"), + message = "Use stateContent instead.", + replaceWith = ReplaceWith("stateContent(block)"), level = DeprecationLevel.WARNING, ) @Suppress("ComposableNaming") @Composable - inline fun render(block: @Composable ViewStore.() -> Unit) = renderState(block) + inline fun render(block: @Composable ViewStore.() -> Unit) = stateContent(block) /** * Collects only events of type [E2] while this composable is in the composition. @@ -89,7 +89,7 @@ class ViewStore internal constructor( */ @Suppress("ComposableNaming") @Composable - inline fun collectEvent(noinline block: ViewStore.(event: E2) -> Unit) { + inline fun eventEffect(noinline block: ViewStore.(event: E2) -> Unit) { val currentViewStore = rememberUpdatedState(this) val currentBlock = rememberUpdatedState(block) LaunchedEffect(eventFlow) { @@ -100,20 +100,20 @@ class ViewStore internal constructor( } @Deprecated( - message = "Use collectEvent instead.", - replaceWith = ReplaceWith("collectEvent(block)"), + message = "Use eventEffect instead.", + replaceWith = ReplaceWith("eventEffect(block)"), level = DeprecationLevel.WARNING, ) @Suppress("ComposableNaming") @Composable - inline fun handle(noinline block: ViewStore.(event: E2) -> Unit) = collectEvent(block) + inline fun handle(noinline block: ViewStore.(event: E2) -> Unit) = eventEffect(block) } /** * Remembers a [Store], collects its state as Compose state, and exposes it through a [ViewStore]. * * Collecting [Store.state] starts the Store immediately. - * Because [ViewStore.collectEvent] starts collecting later from a [LaunchedEffect], startup events + * Because [ViewStore.eventEffect] starts collecting later from a [LaunchedEffect], startup events * such as events emitted from an initial `enter {}` handler may be emitted before handlers in the * same composition begin observing them. * diff --git a/koma-compose/src/jvmTest/kotlin/io/github/komakt/koma/compose/ViewStoreJvmTest.kt b/koma-compose/src/jvmTest/kotlin/io/github/komakt/koma/compose/ViewStoreJvmTest.kt index cd60aaae..df0ab16f 100644 --- a/koma-compose/src/jvmTest/kotlin/io/github/komakt/koma/compose/ViewStoreJvmTest.kt +++ b/koma-compose/src/jvmTest/kotlin/io/github/komakt/koma/compose/ViewStoreJvmTest.kt @@ -32,18 +32,18 @@ class ViewStoreJvmTest { private val testDispatcher = UnconfinedTestDispatcher() @Test - fun renderState_callsBlockOnlyForMatchingState() = runTest(testDispatcher) { + fun stateContent_callsBlockOnlyForMatchingState() = runTest(testDispatcher) { val renderedValues = mutableListOf() withComposition( content = { ViewStore(state = UiState.Ready(10)) - .renderState { + .stateContent { renderedValues += state.value } ViewStore(state = UiState.Loading) - .renderState { + .stateContent { renderedValues += state.value } }, @@ -53,7 +53,7 @@ class ViewStoreJvmTest { } @Test - fun collectEvent_collectsOnlySpecifiedEventType() = runTest(testDispatcher) { + fun eventEffect_collectsOnlySpecifiedEventType() = runTest(testDispatcher) { val events = MutableSharedFlow(extraBufferCapacity = 4) val handled = mutableListOf() @@ -62,7 +62,7 @@ class ViewStoreJvmTest { ViewStore( state = UiState.Ready(0), eventFlow = events, - ).collectEvent { event -> + ).eventEffect { event -> handled += event } }, @@ -76,7 +76,7 @@ class ViewStoreJvmTest { } @Test - fun collectEvent_usesLatestViewStoreAndLambdaAfterRecomposition() = runTest(testDispatcher) { + fun eventEffect_usesLatestViewStoreAndLambdaAfterRecomposition() = runTest(testDispatcher) { val events = MutableSharedFlow(extraBufferCapacity = 4) val handled = mutableListOf() var label = "initial" @@ -99,7 +99,7 @@ class ViewStoreJvmTest { ViewStore( state = viewState, eventFlow = events, - ).collectEvent { event -> + ).eventEffect { event -> handled += "${(state as UiState.Ready).value}:$label:${event.value}" } } @@ -111,7 +111,7 @@ class ViewStoreJvmTest { ViewStore( state = viewState, eventFlow = events, - ).collectEvent { event -> + ).eventEffect { event -> handled += "${(state as UiState.Ready).value}:$label:${event.value}" } } @@ -131,7 +131,7 @@ class ViewStoreJvmTest { @Suppress("DEPRECATION") @Test - fun render_delegatesToRenderState() = runTest(testDispatcher) { + fun render_delegatesToStateContent() = runTest(testDispatcher) { val renderedValues = mutableListOf() withComposition( @@ -148,7 +148,7 @@ class ViewStoreJvmTest { @Suppress("DEPRECATION") @Test - fun handle_delegatesToCollectEvent() = runTest(testDispatcher) { + fun handle_delegatesToEventEffect() = runTest(testDispatcher) { val events = MutableSharedFlow(extraBufferCapacity = 4) val handled = mutableListOf() @@ -162,11 +162,11 @@ class ViewStoreJvmTest { } }, afterSetContent = { - assertTrue(events.tryEmit(UiEvent.ValueChanged(99))) + assertTrue(events.tryEmit(UiEvent.ValueChanged(100))) }, ) - assertEquals(listOf(UiEvent.ValueChanged(99)), handled) + assertEquals(listOf(UiEvent.ValueChanged(100)), handled) } @Test