@@ -26,7 +26,7 @@ import kotlinx.coroutines.flow.filter
26
26
27
27
@Suppress(" unused" )
28
28
@Stable
29
- class ViewStore <S : State , A : Action , E : Event > private constructor(
29
+ class ViewStore <S : State , A : Action , E : Event > internal constructor(
30
30
val state : S ,
31
31
val dispatch : (action: A ) -> Unit ,
32
32
val eventFlow : Flow <E >,
@@ -46,7 +46,7 @@ class ViewStore<S : State, A : Action, E : Event> private constructor(
46
46
if (state is S2 ) {
47
47
block(
48
48
remember(state) {
49
- create (
49
+ viewStore (
50
50
state = state,
51
51
dispatch = dispatch,
52
52
eventFlow = eventFlow,
@@ -66,6 +66,7 @@ class ViewStore<S : State, A : Action, E : Event> private constructor(
66
66
}
67
67
68
68
companion object {
69
+ @Deprecated(" Use viewStore() function instead" )
69
70
fun <S : State , A : Action , E : Event > create (state : S , dispatch : (action: A ) -> Unit , eventFlow : Flow <E >): ViewStore <S , A , E > {
70
71
return ViewStore (
71
72
state = state,
@@ -74,6 +75,7 @@ class ViewStore<S : State, A : Action, E : Event> private constructor(
74
75
)
75
76
}
76
77
78
+ @Deprecated(" Use viewStore() function instead" )
77
79
fun <S : State , A : Action , E : Event > mock (state : S ): ViewStore <S , A , E > {
78
80
return ViewStore (
79
81
state = state,
@@ -84,6 +86,14 @@ class ViewStore<S : State, A : Action, E : Event> private constructor(
84
86
}
85
87
}
86
88
89
+ fun <S : State , A : Action , E : Event > viewStore (state : S , dispatch : (action: A ) -> Unit = {}, eventFlow : Flow <E > = emptyFlow()): ViewStore <S , A , E > {
90
+ return ViewStore (
91
+ state = state,
92
+ dispatch = dispatch,
93
+ eventFlow = eventFlow,
94
+ )
95
+ }
96
+
87
97
@Suppress(" unused" )
88
98
@Composable
89
99
fun <S : State , A : Action , E : Event > rememberViewStore (store : Store <S , A , E >, autoDispose : Boolean = false): ViewStore <S , A , E > {
@@ -100,7 +110,7 @@ fun <S : State, A : Action, E : Event> rememberViewStore(store: Store<S, A, E>,
100
110
}
101
111
102
112
return remember(state) {
103
- ViewStore .create (
113
+ ViewStore (
104
114
state = state,
105
115
dispatch = rememberStore::dispatch,
106
116
eventFlow = rememberStore.event,
@@ -133,7 +143,7 @@ fun <S : State, A : Action, E : Event> rememberViewStore(saver: Saver<S?, out An
133
143
}
134
144
135
145
return remember(state) {
136
- ViewStore .create (
146
+ ViewStore (
137
147
state = state,
138
148
dispatch = store::dispatch,
139
149
eventFlow = store.event,
@@ -194,7 +204,7 @@ fun <S : State, A : Action, E : Event> rememberViewStoreSaveable(
194
204
}
195
205
196
206
return remember(state) {
197
- ViewStore .create (
207
+ ViewStore (
198
208
state = state,
199
209
dispatch = store::dispatch,
200
210
eventFlow = store.event,
0 commit comments