-
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
feat: check connection availability before fetching sourceConfig #103
feat: check connection availability before fetching sourceConfig #103
Conversation
This is to ensure that we don't need to do un-necessary casting of application object
For better readability.
There are few refactors to improve the readability and maintainability of the code.
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.
Great effort!! 🚀
@@ -15,6 +15,7 @@ import org.jetbrains.annotations.VisibleForTesting | |||
* | |||
* @property source The configuration details of a RudderStack source. | |||
*/ | |||
@Suppress("MaximumLineLength") |
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.
NIT: We don't need to suppress MaximumLineLength
rule here. We can have updatedSourceConfig
of NotifyObserversAction
on a new line. For some reason, detekt fails to autocorrect it.
fun Analytics.notifyOnlyOnceOnConnectionAvailable(block: suspend () -> Unit) { | ||
this.analyticsScope.launch { | ||
[email protected] | ||
.filter { it } | ||
.take(ONLY_ONE_ELEMENT) | ||
.collect { block() } | ||
} |
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.
Nice!
@Before | ||
fun setUp() { | ||
Dispatchers.setMain(testDispatcher) |
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.
Remove the Dispatchers.resetMain() from teardown as well.
@@ -34,7 +35,7 @@ internal data class SourceConfig( | |||
) | |||
} | |||
|
|||
class UpdateAction(@VisibleForTesting internal val updatedSourceConfig: SourceConfig) : FlowAction<SourceConfig> { | |||
class NotifyObserversAction(@VisibleForTesting internal val updatedSourceConfig: SourceConfig) : FlowAction<SourceConfig> { |
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.
Suggestion: IMO we should not call it NotifyObserversAction
because notifying the observers is the inherent property of a MutableStateFlow
and it is not the responsibility of this specific action. This action's responsibility is to just update (or set) the sourceConfig state. Thoughts?
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.
Agree. Thanks for the clarification.
private fun runForBaseTypeOnly() { | ||
if (this::class == Analytics::class) { | ||
setLogger(logger = KotlinLogger()) | ||
connectivityState.dispatch(ConnectivityState.SetDefaultStateAction()) | ||
setupSourceConfig() | ||
} |
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.
Great job in detecting this subtle error about base and parent class!
…oved-implement-of-source-config-logic
As it is not needed.
Description
Type of change
Implementation Details
SourceConfigManager
Core Analytics
LoggerAnalytics
Checklist
How to test?
Log:
Breaking Changes
Maintainers Checklist
Screenshots (if applicable)
Additional Context