How to use MVVM with Async Await | Swift Concurrency #14

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ส.ค. 2024
  • Discover the power of combining MVVM architecture with Swift Concurrency and async await to build robust and efficient iOS apps. Learn step-by-step how to implement the MVVM pattern in your Swift projects and leverage the benefits of concurrency for seamless user experiences. Level up your coding skills and create high-performance apps with this comprehensive guide.
    🤙 WELCOME BACK 🤙
    WEBSITE: www.swiftful-thinking.com
    DISCORD: / discord
    GITHUB: github.com/SwiftfulThinking/
    SAY THANKS: www.buymeacoffee.com/nicksarno
    00:00 MVVM
    00:00 Intro
    01:12 Welcome back everybody!
    07:32 MVVM

ความคิดเห็น • 19

  • @farhad28881987
    @farhad28881987 ปีที่แล้ว +9

    Hey Nick,
    It would be GREAT if you can add a new video showing how to write unit tests for viewModels having async await functions.
    You are AWESOME 👏

  • @antontikhonov5028
    @antontikhonov5028 8 หลายเดือนก่อน +2

    Great videos, Nick! One small issue with creating tasks inside the view model in order to keep the UI synchronous is that it makes it harder to unit-test it. For instance if updateData() was an async function, all you would need to do in the test is to await and check data property. Otherwise you will probably need to convert the data property to an async sequence and await until it emits a particular value or times out.

  • @coder7322
    @coder7322 ปีที่แล้ว +2

    So excited to watch this, been thinking about architecture a lot recently. Would be keen to see more content from you on architecture/design patterns 🤓

  • @xybnedasdd2930
    @xybnedasdd2930 ปีที่แล้ว

    I like how Swift Concurrency is taking all the good things from Kotlin Coroutines (context switching behind the scenes, async streams) and doing it in its own flavor.

  • @bonifacy9511
    @bonifacy9511 ปีที่แล้ว

    THank you Nick for all of your hard work!

  • @oleksandrstepanov6652
    @oleksandrstepanov6652 ปีที่แล้ว

    The best! Thanks!

  • @user-eg7ep8db8j
    @user-eg7ep8db8j ปีที่แล้ว

    wonderful video, thanks!!

  • @AdailtonSilvaSP
    @AdailtonSilvaSP 4 หลายเดือนก่อน

    tks for this video! I am going to use it on my project

  • @thaisfernandes7498
    @thaisfernandes7498 9 หลายเดือนก่อน

    You are awwwwesome. Me and my colleagues are always waiting for you to upload new videos. Thanks!!

  • @asadchattha3470
    @asadchattha3470 3 หลายเดือนก่อน

    Thanks Nick

  • @tmjromao
    @tmjromao ปีที่แล้ว

    Many thanks for making, publishing, explaining how to implement the MVVM pattern in Swift. Could you do other(s) explaining the edge cases you mention?, Many thanks, best regards

  • @rahulchaurasia5011
    @rahulchaurasia5011 ปีที่แล้ว

    thanks for wonderful video ... we need more on mvvm pattern please make with realtime api

  • @vncsnts_
    @vncsnts_ ปีที่แล้ว

    In a case I want to pass an EnvironmentObject from the view to view model, for example a service that is passed as an environmentObject, what is the correct way to pass that to the vm so only vm does the actions

  • @ShooMPozitiV
    @ShooMPozitiV ปีที่แล้ว

    And how it will work if I tap button many times? I have to cancel previous task before? If I will have many functions with different things will I have to do many task variables for this?

  • @lincolndickerson1293
    @lincolndickerson1293 ปีที่แล้ว

    First the separation of managers and viewmodels is critical. It really cleans up so much code.
    Not saying never, but I have found .onAppear, .task, and .onDisappear can be problimatic for manager code because a view “appears” and “disappear” more often than you might suspect and enhancements may cause them to fire at the wrong times.
    .task is sometimes described as onappear with a Task built in. There seems to be some subtle differences
    After working through the Firebase playlist so much became clear.
    Pre loading on startup for environment objects, Creating and loading and then injecting observed objects from one level up then reloading on user actions in the view is much more stable and drives down the psychometric complexity and far less business logic in the view.

  • @user-kn6fg4yv2w
    @user-kn6fg4yv2w 9 หลายเดือนก่อน

    so confused video

    • @SwiftfulThinking
      @SwiftfulThinking  9 หลายเดือนก่อน

      Did you watch the rest of the playlist?

  • @brandonhopkins3438
    @brandonhopkins3438 ปีที่แล้ว

    Strange because when I put the whole class on @MainActor, the main view complains. But if the @MainActor is on the private(set) and on the Task, it doesn't 😢