Observer pattern in swift Hindi tutorial
HTML-код
- Опубликовано: 8 сен 2024
- 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: www.youtube.co...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-----------------------------------------------------------------------------------------------------------------------
📥 Download the source code from
Github: github.com/cod...
Google Drive: drive.google.c...
-----------------------------------------------------------------------------------------------------------------------
🎶 Royalty-free Music: www.bensound.com
************************************************************
Connect with me on social media
📧: codecat15@gmail.com
🐦: / codecat15
Facebook: / code.cat.792
Github: github.com/cod...
************************************************************
#ObserverPatternInSwift #KVO #ObserverPatternExample
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 😀
Very thankful to u.. I'm beginner in Swift. The most time consuming in Swift is auto layout... Making One cell takes 2 hours.
Appreciate the detailed explanation with a very thorough example, this was very good tutorial for observer pattern
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 😊
Nice Video Ravi... Could you please make video on RxSwift as well? Also combine in swift....and their implementation in MVVM
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. 😂
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
Great tutorial, but you could've used switch case and enums for colors.
Appreciate your work bhai. Thank you so much for your effort.
instead of writing traffic color in struc, why you didn't prefer enum type?
correct that is a good observation thanks for pointing that out :)
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?
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
Nice Explanation
Thanks and welcome
Awesome explain with real life example . Sir please make video on KVO and KVC . Thanks in advance
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
@@CodeCat15 :)) yes sir , actually I am prepare for interview. thanks sir
I am searching a lot after that find a great knowledgable channel who represent complex iOS in very simple way with Hindi language .
All the very best for your interviews, hope you crack them and give me the good news soon 👍
Thank you for your bright words Mandeep it means a lot to me 🙏
And sir plz make Playlist on Autolayout.
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
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.
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?
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.
Could you please share the link of RxSwift video
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.
@@CodeCat15 thanks bro
when are releasing the KVO video?
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 RUclips.
Can you share me your git link
All my social handles and github link is present in every video description, given is my github profile
github.com/codecat15
Please remove intro of section of video
add in last it will we more good
Hey @Arjun welcome to the channel, by Intro you mean the 10 seconds video?