How can apply similar logic for Firestore requests? This looks so elegant and simple. However, my firestore requests are full of dispatch groups and chained network request codes.
@EssentialDeveloper5 ай бұрын
Hi! You could wrap the Firestore requests in Combine publishers.
@leoyu47823 жыл бұрын
on 9:25, you mentioned there was a dependency between the two requests, we could use FlatMap. Can you please explain why the dependency would make FlatMap a good candidate for chaining the two requests ? thanks!
@EssentialDeveloper3 жыл бұрын
Hi Leo! `FlatMap` allows you to transform elements from an upstream publisher into a new publisher. So, in this case, we transform the received result of the first request into a new publisher to load the second request. Docs: developer.apple.com/documentation/combine/publishers/flatmap
@roh9934 Жыл бұрын
It is also very important to note that flatMap works only when the Error Type of both Publishers are same.
@ThatCronus2 жыл бұрын
This was extremely helpful. Thank you. What if I wanted loadUserDetails() to also return the User? AnyPublisher
@EssentialDeveloper2 жыл бұрын
Hello Joe! In this case, you can Map the result of the Zip publisher to add the User in the tuple ✅
@Sebastian-jy8nh2 жыл бұрын
What about async-await taking in consideration? Assuming we've got iOS 15 as min. iOS version
@EssentialDeveloper2 жыл бұрын
Hi Sebastian. Async/Await also composes well when chaining dependent requests. You can perform one request at a time without completion blocks ✅
@shaileshphalgune38132 жыл бұрын
What if we want to chain the requests in such a way that, second request should be called only if first request is successful.. ? How can we do that ?
@EssentialDeveloper2 жыл бұрын
Hi! FlatMap is only called when the request is successful ✅
@Neonyziee Жыл бұрын
Can we make a chain that behaves in a manner if any of the chained or concurrent requests fail, publisher gives an error?
@arbenjusuf3 жыл бұрын
How to communicate Loader results to Controllers? Are we using an adapter with a callback? Or is it OK to sink and receive loader AnyPublisher results in ViewModels? And from VM, Controllers get changes stream?
@EssentialDeveloper3 жыл бұрын
Hi! It depends on what you're trying to achieve. If you want to decouple the ViewModel from the Loader, you can use an Adapter to direct the results to the ViewModel. The same with the Controller!
@OG4TheStreet3 жыл бұрын
Waw, this is awesome guys, thanks a lot for this beautiful content, this is the first time I am seeing Zip in action
@fiqrihafzain2820 Жыл бұрын
where is this code lives? use cases or repository?
@EssentialDeveloper Жыл бұрын
Hi! Network requests live in the infrastructure layer.
@FrancescoChiusolo3 жыл бұрын
How would you do that prior to iOS 13 where Combine is not available? PS: avoiding closures of course :), in the same declarative way.
@EssentialDeveloper3 жыл бұрын
Hi Francesco! By creating composable objects with a shared polymorphic interface (pretty much how Combine does it!). We showed how to do it in other mentoring sessions - but they're only available to students of the iOS Lead Essentials now.
@justknot44813 жыл бұрын
i find some similarity with pyton 🤔🙃
@ganeshmodi25653 жыл бұрын
not able to hit bell icon getting "This action is turned off for content made for kids"
@EssentialDeveloper3 жыл бұрын
Probably a bug on the KZbin app because this content is flagged as *not* for kids! Please, try again from a different browser/app. Thanks!