-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
updated to use correct comparison for distinctUntilChanged #97
updated to use correct comparison for distinctUntilChanged #97
Conversation
) | ||
} else if (inFlightCall != null && !inFlightCall.isCanceled()) { | ||
} else if (inFlightCall != null && !inFlightCall.isCanceled() && !inFlightCall.isExecuted()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not cancel completed requests
|
||
fun getFeaturesReceivedFlow() = featuresReceivedFlow.asSharedFlow() | ||
|
||
fun startWatchingContext() { | ||
unleashScope.launch { | ||
unleashContext.distinctUntilChanged { old, new -> old != new }.collect { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Values in state flow are conflated using Any.equals comparison in a similar way to distinctUntilChanged operator. It is used to conflate incoming updates to value in MutableStateFlow and to suppress emission of the values to collectors when new value is equal to the previously emitted one. State flow behavior with classes that violate the contract for Any.equals is unspecified.
) : Closeable { | ||
companion object { | ||
private const val TAG = "UnleashFetcher" | ||
} | ||
|
||
private var contextForLastFetch: UnleashContext? = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hold the last fetched so we can ignore refreshing toggles when context has change due to a sync setContext which avoids 2 fetch calls for the same context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good team work!
Make sure we fetch when we setContextAsync, but also make sure we don't fetch twice when we setContext (sync method).
Fix #96