File tree Expand file tree Collapse file tree 3 files changed +15
-5
lines changed
core/src/main/java/io/snabble/sdk/payment Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ All notable changes to this project will be documented in this file.
77### Removed
88### Fixed
99
10+ ## [ 0.77.1]
11+ ### Changed
12+ * core: Change the PaymentCredentialsFlow's StateFlow to be a SharedFlow w/o replaying and state management
13+
1014## [ 0.77.0]
1115### Added
1216* core/ui: Add a feature to pass payment credentials w/o saving it into storage
Original file line number Diff line number Diff line change 22
33package io.snabble.sdk.payment
44
5- import kotlinx.coroutines.flow.MutableStateFlow
5+ import kotlinx.coroutines.MainScope
6+ import kotlinx.coroutines.flow.MutableSharedFlow
67import kotlinx.coroutines.flow.SharedFlow
78import kotlinx.coroutines.flow.asSharedFlow
9+ import kotlinx.coroutines.launch
810
911internal interface MutableCredentialsFlow {
1012
11- fun tryEmitCredentials (credentials : PaymentCredentials ): Boolean
13+ fun emitCredentials (credentials : PaymentCredentials )
1214}
1315
1416/* *
@@ -20,13 +22,17 @@ internal interface MutableCredentialsFlow {
2022 */
2123object PaymentCredentialsFlow : MutableCredentialsFlow {
2224
23- private val _credentialsFlow = MutableStateFlow <PaymentCredentials ?>(null )
25+ private val _credentialsFlow = MutableSharedFlow <PaymentCredentials ?>()
2426
2527 /* *
2628 * Collect this flow to be notified if payment credentials has been created successfully.
2729 * If there are no collectors, it will be discarded.
2830 */
2931 val credentialsFlow: SharedFlow <PaymentCredentials ?> = _credentialsFlow .asSharedFlow()
3032
31- override fun tryEmitCredentials (credentials : PaymentCredentials ): Boolean = _credentialsFlow .tryEmit(credentials)
33+ override fun emitCredentials (credentials : PaymentCredentials ) {
34+ MainScope ().launch {
35+ _credentialsFlow .emit(credentials)
36+ }
37+ }
3238}
Original file line number Diff line number Diff line change @@ -170,7 +170,7 @@ public synchronized void add(PaymentCredentials credentials) {
170170 }
171171
172172 public synchronized void justEmitCredentials (final PaymentCredentials credentials ) {
173- ((MutableCredentialsFlow ) PaymentCredentialsFlow .INSTANCE ).tryEmitCredentials (credentials );
173+ ((MutableCredentialsFlow ) PaymentCredentialsFlow .INSTANCE ).emitCredentials (credentials );
174174 }
175175
176176 /**
You can’t perform that action at this time.
0 commit comments