Adv. Swift Combine Framework: Debounce Search Optimization

  Рет қаралды 20,813

Lets Build That App

Lets Build That App

Күн бұрын

Often with mobile apps, we want to conserve the amount of data that is being consumed by users. This can help to save battery life and mobile data on their monthly bills. Newly introduced in Combine is a method called debounce that allows us to throttle changes we receive when typing into a search field. Enjoy.
AppStore JSON APIs
www.letsbuildthatapp.com/cour...
Tinder Firestore Swipe and Match
www.letsbuildthatapp.com/cour...
Twitter Slide Out Menu Course
www.letsbuildthatapp.com/cour...
Podcasts Course
www.letsbuildthatapp.com/cour...
Intermediate Training Core Data
www.letsbuildthatapp.com/cour...
Instagram Firebase Course
www.letsbuildthatapp.com/cour...
Facebook Group
/ 1240636442694543
Completed Source Code
www.letsbuildthatapp.com/cour...
Instagram: / buildthatapp
Twitter: / buildthatapp
Hackintosh Build
i9 9900k: amzn.to/2CvQj6v
ASUS Z390 Motherboard: amzn.to/2JpaQ2B
16GB Corsair Vengeance RGB RAM: amzn.to/2YbygvJ
Corsair H100i Platinum Water Cooler: amzn.to/2FnbM22
Thermaltake RGB Power Supply: amzn.to/2TgKDTu
Intel 1TB SSD: amzn.to/2Tkdk1V
Corsair 280x Computer Case: amzn.to/2WcjvH2
AMD Radeon 4GB RAM GFX Card: amzn.to/2TYMyAp
LG 34" Widescreen 3440 x 1440: amzn.to/2Tk7q0S
Rode NT1 Microphone: amzn.to/2TZgX1r
Focusrite Audio Interface: amzn.to/2U12gey
Panasonic GH4 DSLR: amzn.to/2U4BrG6
Magewell HDMI to USB3 Capture Card: amzn.to/2Jp2esI

Пікірлер: 70
@drinknation7260
@drinknation7260 5 жыл бұрын
Absolutely killing it with these videos. Liking the advanced content and the comedy.
@bdaralan
@bdaralan 5 жыл бұрын
Awesome, been waiting for Brian to show some of the Combine stuffs.
@gjermundification
@gjermundification 5 жыл бұрын
Good one! This is also imperative for submitting a form. Such as submitting an order from shopping cart.
@josejimenez7502
@josejimenez7502 3 жыл бұрын
So rad I had no idea this was an advanced concept in Swift, I've just begun learning this within the past two weeks, and Combine really helped me understand how to hit an API and bring data into the application.
@bennychewDev
@bennychewDev 5 жыл бұрын
Good video Brian, thanks for sharing! I like the accent at the beginning of the video. By the way: I think the chinese accent you did in prev video was Cantonese style english. :) Glad to see Combine offers very similar functionality compared to RxSwift, so learning Rx wasn't in vain up until now.
@9988khan
@9988khan 5 жыл бұрын
Hi 👋 brian nice to see you again with another video, just waiting for your video thanks from india
@avazbekolimov5739
@avazbekolimov5739 Жыл бұрын
THANKS you for both source code and great explanation of combine!!!
@zainhaider6628
@zainhaider6628 5 жыл бұрын
i have learned a lot from you. keep making nice video!
@tamilselvan-cc9kp
@tamilselvan-cc9kp 5 жыл бұрын
wow. i have been using dispatch blocks and making my logic complex for doing this same feature. This looks so simple.
@abdouett3676
@abdouett3676 5 жыл бұрын
Thanks brian! We are looking for more combine tutos plz.
@rahuljamba5846
@rahuljamba5846 2 жыл бұрын
Thanks a lot for sharing this excellent tricks.❤️👍
@kidrainen01
@kidrainen01 5 жыл бұрын
Tank top Brain back at it!
@RhLCali
@RhLCali 5 жыл бұрын
Good stuff Brian. Also if you want to avoid the explicitly unwrapping the notification object you can use compactMap _ = NotificationCenter.default.publisher(for: UITextField.textDidChangeNotification, object: textField) .compactMap{ ($0.object as? UITextField)?.text } .debounce(for: 0.5, scheduler: RunLoop.main) .removeDuplicates() .sink { print("Search text:", $0) }
@donathmm3881
@donathmm3881 5 жыл бұрын
What does compactMap
@brazo98
@brazo98 5 жыл бұрын
Dude thx a lot for your movie! Dude is something happen with your microphone? Hell, it comes and goes! Ok no problem! Thanks for you all cool movies! Nice weekend.
@LetsBuildThatApp
@LetsBuildThatApp 5 жыл бұрын
Can you tell me which part of the clip has bad audio?
@rajanmaheshwari
@rajanmaheshwari 5 жыл бұрын
Somewhere in Rx let searchResults = textFieldSearch.rx.text.orEmpty.skip(1) .debounce(0.5, scheduler: MainScheduler.instance) .flatMapLatest { query -> Observable in { //Your Business Logic } Apple is just mimicking the RxSwift's behaviour. Thanks for the video.
@LetsBuildThatApp
@LetsBuildThatApp 5 жыл бұрын
Indeed, Rx team did a great job ushering in these concepts. Now it'll be a standard.
@michalziobro1984
@michalziobro1984 5 жыл бұрын
They should have done this as Android gets Live Data and observable etc.
@priceringo1756
@priceringo1756 5 жыл бұрын
Thanks for the Combine video. Instead of mapping every notification event to a string and then debouncing that stream of strings, it would be more efficient to debounce the notification event publisher and then convert the notification to a string (once).
@LetsBuildThatApp
@LetsBuildThatApp 5 жыл бұрын
Marvelous
@rishabhshukla725
@rishabhshukla725 5 жыл бұрын
First thing first . I missed you alot 😂😂 seriously sir . I missed your real voice.
@digviju001
@digviju001 5 жыл бұрын
Hmm good one... I'm looking to make use of this..
@sreekanthiragam2305
@sreekanthiragam2305 4 жыл бұрын
@bryan why we need to use sync chain call when map is going to provide the closure of the returned string values.
@maxcodes
@maxcodes 5 жыл бұрын
Thank god for your channel. Everyone else's content is super basic, including my own videos haha.
@LetsBuildThatApp
@LetsBuildThatApp 5 жыл бұрын
There's often a lot more interesting gems when one digs deep enough into the apis.
@NPCTE23
@NPCTE23 4 жыл бұрын
Something’s changed in the apple API this code doesn’t work no more :/
@LetsBuildThatApp
@LetsBuildThatApp 4 жыл бұрын
Yeah, unfortunately Combine syntax changed significantly after beta.
@Omeir34
@Omeir34 4 жыл бұрын
Exactly what's the new code?
@rajanmaheshwari
@rajanmaheshwari 3 жыл бұрын
I just created the publisher globally and assigned the same to the global variable and it worked. class YourVC { var publisher: AnyCancellable! func yourFunction() { self.publisher = //the code in the video } } Also in viewWillDissappear I cancelled the publisher.
@VeryBlueBot
@VeryBlueBot 5 жыл бұрын
haha best opening ever :)
@Eric-bq4db
@Eric-bq4db 5 жыл бұрын
Wow. Combine Framework fixed the RxSwift. Swift UI fixed SnapKit
@donathmm3881
@donathmm3881 5 жыл бұрын
Awesoooome
@worldsorudecorp5650
@worldsorudecorp5650 5 жыл бұрын
hi , can you print 1 2 3 4 3 2 1 with just a single for loop.. no other loop or conditional statements... its a challenge for every one
@samirdesigner3324
@samirdesigner3324 5 жыл бұрын
thanks if make video how connect account apple with iMac and connect with xcode new way 2019 thanks
@alileventkeskinalemdag5728
@alileventkeskinalemdag5728 2 жыл бұрын
I tried your code but it seems it doesn't work anymore. I don't know why. There is nothing happening when I typing.
@brotherlove8241
@brotherlove8241 5 жыл бұрын
Is it best to use pagination after searching, if the results are long?
@LetsBuildThatApp
@LetsBuildThatApp 5 жыл бұрын
Yes
@mukulbakshi28
@mukulbakshi28 5 жыл бұрын
Very Knowledgable, Love it and dont be professor again.
@LetsBuildThatApp
@LetsBuildThatApp 5 жыл бұрын
I don't control the professor, the professor controls me.
@donathmm3881
@donathmm3881 5 жыл бұрын
@@LetsBuildThatApp 😂😂😂😂
@donathmm3881
@donathmm3881 5 жыл бұрын
Please more
@fernandoflorez8646
@fernandoflorez8646 3 жыл бұрын
It would be great if you add subtitles to your videos.
@MubasherMurtaza
@MubasherMurtaza 5 жыл бұрын
Dear, Use single line for Search instead of search bar let value = searchValue.filter { return ($0?.name.lowercased().contains(String(sender.text!.lowercased())))! }
@LetsBuildThatApp
@LetsBuildThatApp 5 жыл бұрын
Why?
@MubasherMurtaza
@MubasherMurtaza 5 жыл бұрын
Dear, Simple, short method & suggestions! searchValue = [Contains Data] 1--> let value = searchValue.filter { return ($0?.name.lowercased().contains(String(sender.text!.lowercased())))! } if value != []{ countries = value }else{ countries = [] } 2--> var countries{ didSet{ Reload TableData } }
@LetsBuildThatApp
@LetsBuildThatApp 5 жыл бұрын
This looks like it doesn’t use the combine framework.
@stigblue
@stigblue 5 жыл бұрын
RxSwift vs Combine. Thoughts?
@w0mblemania
@w0mblemania 5 жыл бұрын
Combine if you are able to require iOS 13. RxSwift if you want to support everyone. Also, Combine doesn't fully support UIKit, unlike RxSwift/Cocoa.
@petethorne5094
@petethorne5094 5 жыл бұрын
This whole demo is UIKit though? What parts are not supported?
@w0mblemania
@w0mblemania 5 жыл бұрын
@@petethorne5094 Notice that the code doesn't bind to a UIView itself; instead it relies on a subscription to a UINotification (text editing). Having to do this kind of thing for every UIKit element -- even if possible (which it's probably not) is going to be super-tedious.
@petethorne5094
@petethorne5094 5 жыл бұрын
w0mbles ah ok. And RxSwift doesn’t have this limitation?
@w0mblemania
@w0mblemania 5 жыл бұрын
@@petethorne5094 RxSwift has a companion (sub-) framework RxCocoa; it's community has provided many bindings many to UIView/UIViewControls, as well as a facility for UIView subclasses to define their own bindings. We'll have to wait and see if Apple provide anything like that, but so far, it appears that they won't be, instead preferring to concentrate on SwiftUI.
@shreebhagwat1009
@shreebhagwat1009 5 жыл бұрын
Don't do drugs, Drugs are bad. Mkay ,Mkay
@w0mblemania
@w0mblemania 5 жыл бұрын
It's such a massive shame this is (and SwiftUI) is available for iOS 13. It cuts off access for many millions of users. But since Combine is a clone of RxSwift, and Combine doesn't really support UIKit, I'm just going to use RxSwift for the next 2 to 3 years, as a bridge to the future.
@LetsBuildThatApp
@LetsBuildThatApp 5 жыл бұрын
Luckily iOS adoption is fairly fast compared to android. But still it is a whiles away.
@bennychewDev
@bennychewDev 5 жыл бұрын
I agree. It will be good to learn RxSwift now anyway imo, because Rx is also available on other platforms. The paradigm will be the same on RxJs, RxJava, etc, only slightly different syntax.
@mmatyjaszczyk21
@mmatyjaszczyk21 5 жыл бұрын
Always dreamed to be first. Thats the day 😏
@cularu1
@cularu1 5 жыл бұрын
Rx behaviour
@user-vl4vo2vz4f
@user-vl4vo2vz4f 3 жыл бұрын
No documentation yet? Why bother. Apple documentation is crap.
@gabrielrml
@gabrielrml 5 жыл бұрын
Try a London accent ...mate
@Kingkeishan
@Kingkeishan 5 жыл бұрын
First things first, cocaine is a hell of a drug...ok enough of British accent.......???lol wth
Combine. Введение в фреймворк
21:46
SwiftBook
Рет қаралды 14 М.
Download JSON from API in Swift with Combine | Continued Learning #23
34:43
EVOLUTION OF ICE CREAM 😱 #shorts
00:11
Savage Vlogs
Рет қаралды 12 МЛН
Inside Out 2: Who is the strongest? Joy vs Envy vs Anger #shorts #animation
00:22
Пранк пошел не по плану…🥲
00:59
Саша Квашеная
Рет қаралды 7 МЛН
Inside Out Babies (Inside Out Animation)
00:21
FASH
Рет қаралды 23 МЛН
When to Semaphore vs Dispatch Group! Careful Multithreaded Shared Resource
11:11
Why I *highly dislike* iOS Development
10:38
mayuko
Рет қаралды 346 М.
Live Searching an API Using SwiftUI Searchable
22:55
azamsharp
Рет қаралды 7 М.
Swift API Calls for Beginners (Networking) - Async Await & JSON
25:35
Advanced Swift Generics: Best Solution to Eliminate Code Duplication!
17:18
Lets Build That App
Рет қаралды 38 М.
JPEG is Dying - And that's a bad thing
8:09
2kliksphilip
Рет қаралды 20 М.
Swift 5 Brand New Result Type: Write Cleaner API code
13:09
Lets Build That App
Рет қаралды 55 М.
The power of Combine
15:48
Swift and Tips
Рет қаралды 2,9 М.
EVOLUTION OF ICE CREAM 😱 #shorts
00:11
Savage Vlogs
Рет қаралды 12 МЛН