Skip to content
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

[KTLN-759] Combine 2 Kotlin State Flows Into a Single State Flow #1093

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

naoussi
Copy link
Contributor

@naoussi naoussi commented Sep 13, 2024

Added unit tests

Comment on lines 35 to 48
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-test</artifactId>
<version>1.7.3</version>
<type>pom</type>
</dependency>

<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-core</artifactId>
<version>1.8.1</version>
<type>pom</type>
<scope>runtime</scope>
</dependency>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's extract these versions as properties.

See line 53 for an example of that.

Suggested change
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-test</artifactId>
<version>1.7.3</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-core</artifactId>
<version>1.8.1</version>
<type>pom</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-test</artifactId>
<version>${kotlinx-coroutines.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-core</artifactId>
<version>${kotlinx-coroutines.version}</version>
<type>pom</type>
<scope>runtime</scope>
</dependency>

<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-test</artifactId>
<version>1.7.3</version>
<type>pom</type>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a pom type? Wouldn't this just be a normal dependency? If anything, wouldn't this be a <scope>test</scope> dependency?

Suggested change
<type>pom</type>
<scope>test</scope>

Comment on lines 46 to 47
<type>pom</type>
<scope>runtime</scope>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this type declaration, and this is probably a compile dependency, so we shouldn't need this scope declaration here.

Suggested change
<type>pom</type>
<scope>runtime</scope>

Comment on lines 56 to 74
// @Test
// fun `zip operator waits for both flows to emit`() = runTest {
// val stateFlow1 = MutableStateFlow(5)
// val stateFlow2 = MutableStateFlow("Hi")
//
// val zippedStateFlow = stateFlow1.zip(stateFlow2) { value1, value2 ->
// value1 to value2
// }
//
// assertEquals(Pair(5, "Hi"), zippedStateFlow.first())
//
// stateFlow1.value = 11
//
// assertEquals(Pair(11, "Hi"), zippedStateFlow.first())
//
// stateFlow2.value = "World"
// assertEquals(Pair(11, "World"), zippedStateFlow.first())
// }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test looks like it would be very promising, can we use this style instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants