Replies: 1 comment
-
Sure it does. All that I suspect you are confusing the types created as the chain is set up with the types that propagate through the chain itself.
is the same as
The closure is just an argument to
|
Beta Was this translation helpful? Give feedback.
-
Hi,
I'm trying to wrap my head around the promise concept and I'm having some issue when dealing with HTTP GET requests.
I have a function
f
that calls an HTTP endpoint, decodes some JSON and returns a Swift object after doing some transformations on an intermediate type:rgp
in this case is an object containing an array of objects.Now, I need to bolt several other HTTP calls, which should be executed for a subset of
rgp
components:As far as I understand,
compactMap
does not permit chaining other promises withthen
because it doesn't return aPromise
itself.What's the best way to tackle this situation?
I do not know the subset of object to work with before the second
compactMap
ends.I tried embedding the
when
logic in the lattercompactMap
but since it's all async the wrapping closure returns before thewhen
ends, and to be honest it doesn't look good enough.Beta Was this translation helpful? Give feedback.
All reactions