Observer pattern in swift Hindi tutorial

Поділитися
Вставка
  • Опубліковано 27 бер 2020
  • The observer design pattern is the first step towards KVO in swift or Key-value observer, to understand KVO we should know how Observer pattern works, not only KVO third-party libraries like RxSwift uses observer pattern in a much better way so in this swift tutorial we shall learn what is observer pattern with a very simple example on the observer pattern in swift.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ✅ Subscribe to the channel and stay ahead of everyone by following the right way for writing clean code in swift. 🔥🔥🔥🔥🔥
    🔗Click on the link to subscribe: ua-cam.com/users/codecat?sub...
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    -----------------------------------------------------------------------------------------------------------------------
    📥 Download the source code from
    Github: github.com/codecat15/UA-cam-...
    Google Drive: drive.google.com/open?id=1atv...
    -----------------------------------------------------------------------------------------------------------------------
    🎶 Royalty-free Music: www.bensound.com
    ************************************************************
    Connect with me on social media
    📧: codecat15@gmail.com
    🐦: / codecat15
    Facebook: / code.cat.792
    Github: github.com/codecat15
    ************************************************************
    #ObserverPatternInSwift #KVO #ObserverPatternExample

КОМЕНТАРІ • 34

  • @CodeCat15
    @CodeCat15  4 роки тому +6

    Before learning KVO or using any library like RxSwift we should first learn the observer design principle on which these libraries are made. In this video, I am explaining what are the basics of observer pattern with easy examples. Feel free to ask questions on this topic and do share this video with your iOS group and give a thumbs up 😀

  • @ShubhamSharma-qo8go
    @ShubhamSharma-qo8go 4 роки тому +2

    Very thankful to u.. I'm beginner in Swift. The most time consuming in Swift is auto layout... Making One cell takes 2 hours.

  • @NaveenKumar-zp8ev
    @NaveenKumar-zp8ev 3 роки тому +1

    Appreciate the detailed explanation with a very thorough example, this was very good tutorial for observer pattern

    • @CodeCat15
      @CodeCat15  3 роки тому

      Hello Naveen, am glad this video was helpful and worth your time, and thank you for your kind words. Plz do feel free to ask questions on this topic and do share this video with your iOS group on WhatsApp or Facebook 😊

  • @vyankateshshivnikar7932
    @vyankateshshivnikar7932 Рік тому +1

    Nice Video Ravi... Could you please make video on RxSwift as well? Also combine in swift....and their implementation in MVVM

  • @kartheekmanthoju493
    @kartheekmanthoju493 2 роки тому

    Great tutorial, but you could've used switch case and enums for colors.
    Appreciate your work bhai. Thank you so much for your effort.

  • @poojaraghuwanshi1914
    @poojaraghuwanshi1914 Рік тому +1

    Nice Explanation

  • @AnuragKashyap17
    @AnuragKashyap17 4 роки тому +1

    Video start hone se pehle hi I like the video 😅 Maine Abhi notice kia ki mai har baar aisa kar raha hun apne aap hi. 😂

    • @CodeCat15
      @CodeCat15  4 роки тому +1

      Well that’s the most common example i could refer to you know and aisa he hota hai re, mostly swiftui k liye its important to know observer pattern and even for third party like RxSwift as they all work on it

  • @umairahmad4368
    @umairahmad4368 2 роки тому

    Thanks for making such excellent and informative videos. I have one question.
    let vehicleObserver1 = VehicleObserver(_Id: 1)
    let vehicleObserver2 = VehicleObserver(_Id: 2)
    let vendorObserver1 = VendorObserver(_Id: 1)
    let vendorObserver2 = VendorObserver(_Id: 2)
    In the above cause, we are not able to add below 2 observers as they have the same IDs. Similarly how to find that trafficObserver array (having parent type "ObserverProtocol") contains how many objects are from VehicleObserver and VendorObserver separately.
    Any suggestion to solve that.

  • @MandeepSingh-ly3jj
    @MandeepSingh-ly3jj 4 роки тому +1

    Awesome explain with real life example . Sir please make video on KVO and KVC . Thanks in advance

    • @CodeCat15
      @CodeCat15  4 роки тому +1

      Thanks for the video request, I will surely make a video on this as i think this is asked more in interviews so will cover in depth

    • @MandeepSingh-ly3jj
      @MandeepSingh-ly3jj 4 роки тому +1

      @@CodeCat15 :)) yes sir , actually I am prepare for interview. thanks sir

    • @MandeepSingh-ly3jj
      @MandeepSingh-ly3jj 4 роки тому +1

      I am searching a lot after that find a great knowledgable channel who represent complex iOS in very simple way with Hindi language .

    • @CodeCat15
      @CodeCat15  4 роки тому +1

      All the very best for your interviews, hope you crack them and give me the good news soon 👍

    • @CodeCat15
      @CodeCat15  4 роки тому

      Thank you for your bright words Mandeep it means a lot to me 🙏

  • @AshishKumar-gt4bc
    @AshishKumar-gt4bc 4 роки тому +1

    this video was was very informative.
    Also could you explain how this pattern could be used in an app where data coming from API is used as a subject to notify others and subsequently the component that has subscribed or is observing the state of that subject helps in changing the ui of the application or setting data in the ui of the app?

    • @CodeCat15
      @CodeCat15  4 роки тому +5

      This is indeed a charming question, but as I always say in my videos let's do some technical reasoning before we use this pattern for our API parsing
      1. what is the possibility in a mobile application that you call one web service and 2-3 view-models or views are waiting to react on it?
      2. When you call an API you update the UI in the main thread, do you update more than one UI in a mobile app? The answer is NO because at a time the user can just see one UI on his screen.
      3. You may say that what if I want to subscribe to single or multiple properties of a response I receive from the API on view controller A on viewcontroller B, well shouldn't the web API which you will call on viewcontroller B give you latest and greatest data? And if it's just one or two property I am sure we can leverage property injection to do this
      This pattern is useful when you are working with event-based system where each event needs to be acted upon by multiple subscribers, I am still trying to wrap my head around reactive programming as that concept is very new but works on the principles of the observer pattern.
      Also, I don't want to use reactive programming everywhere because a sword cannot be used where a pen is needed so I need solid technical reasons as to use this kind of event-driven programming in my project and to do that we need to analyze the need or should I say the requirements.
      SwiftUI has something similar, which is ObservedObject and @Published and they too work on the same principles but it's just for one single view and I can surely show that in the coming tutorials.
      Does this answer your question, if not then please feel free to ask questions I will be happy to answer them

  • @natureloverspakistan
    @natureloverspakistan 3 роки тому +4

    instead of writing traffic color in struc, why you didn't prefer enum type?

    • @CodeCat15
      @CodeCat15  3 роки тому +3

      correct that is a good observation thanks for pointing that out :)

  • @rishabhsrivastava9849
    @rishabhsrivastava9849 3 місяці тому

    Hey Ravi, Nice session. I have a question that can't we create an array of weak observer? Dont you think adding observer in array will create the retain cycle?

    • @CodeCat15
      @CodeCat15  20 днів тому

      yes, it's a good practice to avoid causing any retain cycles and having weak ensures that it won't happen and ARC will take care of it.

  • @ShubhamSharma-qo8go
    @ShubhamSharma-qo8go 4 роки тому +2

    And sir plz make Playlist on Autolayout.

    • @CodeCat15
      @CodeCat15  4 роки тому

      Yes i will @Shubham, if you have questions on the observer pattern then do ask will be happy to answer those and do subscribe and share this channel with your iOS group

  • @hirakjyotiborah5687
    @hirakjyotiborah5687 2 роки тому

    when are releasing the KVO video?

    • @CodeCat15
      @CodeCat15  2 роки тому +1

      I will try to come up with a short video on this topic soon on my instagram account, and if needed will create a full video on UA-cam.

  • @mazharhameed2523
    @mazharhameed2523 3 роки тому +1

    Could you please share the link of RxSwift video

    • @CodeCat15
      @CodeCat15  3 роки тому +1

      Hey Mazhar, there are no RxSwift videos in the channel yet but soon i may create one or two not more than that as the future of iOS is combine framework.

    • @mazharhameed2523
      @mazharhameed2523 3 роки тому

      @@CodeCat15 thanks bro

  • @ankitarana3551
    @ankitarana3551 4 роки тому +2

    Can you share me your git link

    • @CodeCat15
      @CodeCat15  4 роки тому +1

      All my social handles and github link is present in every video description, given is my github profile
      github.com/codecat15

  • @arjunhanswal3858
    @arjunhanswal3858 4 роки тому

    Please remove intro of section of video
    add in last it will we more good

    • @CodeCat15
      @CodeCat15  4 роки тому

      Hey @Arjun welcome to the channel, by Intro you mean the 10 seconds video?