Skip to content

How to create an instance of SkieSwiftStateFlow in Swift for testing #54

Answered by FilipDolnik
BenedictP asked this question in Q&A
Discussion options

You must be logged in to vote

Hi!

There are multiple options. The easiest one is to write a function in Kotlin that will return a regular Kotlin flow with the behavior you need and just call it from Swift. (and let SKIE convert the Flow to the required SkieSwiftFlow).

You can also use Flow builders from Coroutines (for example: emptyFlow, flowOf, etc.). However, that would require you to export the entire Coroutines library to Swift, which I wouldn't recommend. But you can write simple wrapping functions for those builders to workaround this problem.

Last option: If you have some way of constructing regular Coroutines Flow in Swift, you can use conversion constructors provided by SKIE: SkieSwiftFlow(SkieKotlinFlow< Ui…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by BenedictP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #53 on January 09, 2024 09:20.