Question about skie - I'm trying to set up skie on...
# touchlab-tools
p
Question about skie - I'm trying to set up skie on an older project and can't make sense of the Flow support. Reading the documentation, the converted values are supposed to implement AsyncSequence, but that doesn't seem to be the case when, when I try to treat it as an AsyncSequence, I get error messages:
For-in loop requires 'SkieKotlinFlow<T>' to conform to 'AsyncSequence'
t
Could you share more code for context? (code at call-site + code returning the Flow) This looks like something is returning just the non-bridged type (the one we're looking for is
SkieSwiftFlow<T>
)
p
How do I access the bridged type? I'm accessing the val specified in kotlin:
Copy code
interface Model<TViewState :ViewState> {
  val viewState: Flow<TViewState>
  val navigationEventFlow: Flow<NavigationEvent>
}

interface NavigationEvent
interface ViewState
Copy code
Task.init {
                for await awaitedValue in model.navigationEventFlow {
                    // do something
                }
            }
t
I wasn't able to reproduce it. Could you show the declaration of the
model
used in Swift?
image.png
p
ah it's fairly convoluted, I'll try to dig into it, maybe there was some extra bridging done in the past to create the model
t
What's the type of your
model
property?
The fact it gives you
SkieKotlinFlow
and not
SkieSwiftFlow
is really weird (either a known limitation that @Filip Dolník might remember, or possibly a bug)
If you need a workaround, you can do
for await awaitedValue in SkieSwiftFlow(model.navigationEventFlow)
p
I couldn't find any references to
SkieSwiftFlow
- am I missing an import? It doesn't exist in the header for the generated framework
The
model
property is of
CommonModel
, which is an interface that extends the
Model
interface I mentioned above. On the swift side, it's a
CommonModel
being referenced. The models do have a few generic types associated with it, not sure if that's relevant
f
Hi! > I couldn’t find any references to
SkieSwiftFlow
- am I missing an import? It doesn’t exist in the header for the generated framework It should be enough to import your Kotlin framework. The SkieSwiftFlow is written in Swift so it’s not present in the Obj-C header - only in the Swift header. > The models do have a few generic types associated with it, not sure if that’s relevant It’s possible. The translation from SkieKotlinFlow to SkieSwiftFlow is done automatically by the Swift compiler and there are some cases in which it’s not possible to do, mainly if the Flow is a type argument (generics) In the following example:
Copy code
for await awaitedValue in model.navigationEventFlow {
   // do something
}
What is the exact type of
model
and
model.navigationEventFlow
expressions?