Adv. Swift Combine Framework: Debounce Search Optimization

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

Lets Build That App

Lets Build That App

Күн бұрын

Пікірлер: 70
@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.
@CuriosMindDIY
@CuriosMindDIY 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 4 жыл бұрын
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.
@avazbekolimov5739
@avazbekolimov5739 Жыл бұрын
THANKS you for both source code and great explanation of combine!!!
@rahuljamba5846
@rahuljamba5846 3 жыл бұрын
Thanks a lot for sharing this excellent tricks.❤️👍
@drinknation7260
@drinknation7260 5 жыл бұрын
Absolutely killing it with these videos. Liking the advanced content and the comedy.
@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.
@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?
@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
@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.
@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
@9988khan
@9988khan 5 жыл бұрын
Hi 👋 brian nice to see you again with another video, just waiting for your video thanks from india
@rishabhshukla725
@rishabhshukla725 5 жыл бұрын
First thing first . I missed you alot 😂😂 seriously sir . I missed your real voice.
@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.
@kidrainen01
@kidrainen01 5 жыл бұрын
Tank top Brain back at it!
@bdaralan
@bdaralan 5 жыл бұрын
Awesome, been waiting for Brian to show some of the Combine stuffs.
@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.
@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
@gjermundification
@gjermundification 5 жыл бұрын
Good one! This is also imperative for submitting a form. Such as submitting an order from shopping cart.
@brotherlove8241
@brotherlove8241 5 жыл бұрын
Is it best to use pagination after searching, if the results are long?
@LetsBuildThatApp
@LetsBuildThatApp 5 жыл бұрын
Yes
@samirdesigner3324
@samirdesigner3324 5 жыл бұрын
thanks if make video how connect account apple with iMac and connect with xcode new way 2019 thanks
@zainhaider6628
@zainhaider6628 5 жыл бұрын
i have learned a lot from you. keep making nice video!
@Eric-bq4db
@Eric-bq4db 5 жыл бұрын
Wow. Combine Framework fixed the RxSwift. Swift UI fixed SnapKit
@abdouett3676
@abdouett3676 5 жыл бұрын
Thanks brian! We are looking for more combine tutos plz.
@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.
@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.
@digviju001
@digviju001 5 жыл бұрын
Hmm good one... I'm looking to make use of this..
@fernandoflorez8646
@fernandoflorez8646 4 жыл бұрын
It would be great if you add subtitles to your videos.
@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 😂😂😂😂
@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.
@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.
@donathmm3881
@donathmm3881 5 жыл бұрын
Awesoooome
@mmatyjaszczyk21
@mmatyjaszczyk21 5 жыл бұрын
Always dreamed to be first. Thats the day 😏
@VeryBlueBot
@VeryBlueBot 5 жыл бұрын
haha best opening ever :)
@donathmm3881
@donathmm3881 5 жыл бұрын
Please more
@user-vl4vo2vz4f
@user-vl4vo2vz4f 4 жыл бұрын
No documentation yet? Why bother. Apple documentation is crap.
@shreebhagwat1009
@shreebhagwat1009 5 жыл бұрын
Don't do drugs, Drugs are bad. Mkay ,Mkay
@gabrielrml
@gabrielrml 5 жыл бұрын
Try a London accent ...mate
@cularu1
@cularu1 5 жыл бұрын
Rx behaviour
@Kingkeishan
@Kingkeishan 5 жыл бұрын
First things first, cocaine is a hell of a drug...ok enough of British accent.......???lol wth
SwiftUI Reactive Intro: State Management and Bindings
18:41
Lets Build That App
Рет қаралды 28 М.
Каха и дочка
00:28
К-Media
Рет қаралды 3,4 МЛН
So Cute 🥰 who is better?
00:15
dednahype
Рет қаралды 19 МЛН
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 9 МЛН
SwiftUI - Intro to MVVM | Example Refactor | Model View ViewModel
11:55
Download JSON from API in Swift with Combine | Continued Learning #23
34:43
How to master Combine like a Pro - The Basics 📱 (free iOS tutorial)
2:04:42
This is How I Scrape 99% of Sites
18:27
John Watson Rooney
Рет қаралды 256 М.
try! Swift NYC 2019 - Getting Started with Combine
27:05
try! Swift Conference
Рет қаралды 12 М.
What is a Protocol in Swift and SwiftUI View protocol | Swift Basics #17
9:47
Weak and Unowned Self Closure Memory Leak Fixes
12:21
Lets Build That App
Рет қаралды 57 М.
Reconsidering @Published - Combine to Async Part 1
8:37
Daniel Steinberg
Рет қаралды 1,9 М.
Каха и дочка
00:28
К-Media
Рет қаралды 3,4 МЛН