Build a Reactive Search Filter with Svelte

Поділитися
Вставка
  • Опубліковано 2 лис 2024

КОМЕНТАРІ • 77

  • @mbalslow
    @mbalslow Рік тому +25

    Great video once again!
    A good follow-up video would be to cover the same functionality but instead of doing search already loaded records, it would be up against a REST API with a filter. Possibly with a debounce logic.

    • @Huntabyte
      @Huntabyte  Рік тому +9

      Great idea!

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

      I'm trying to do this now with my Wordpress website and apply some of the things you've taught

    • @marktwain3083
      @marktwain3083 Рік тому +4

      That's exactly what I expected this video to be about, I believe this scenario is more common.
      @@Huntabyte please consider making a video relevant to this topic, you are the only youtuber out there that's so easy to understand and it would be super useful for those of us who are getting started with svelte and sveltekit.

  • @frederikclement7795
    @frederikclement7795 Рік тому +15

    Beautiful! I appreciate how beginner friendly your videos are and help to create real-world functionality. Also great to focus on js first and adding ts later. Thank you!

  • @KevinMacKenzie61
    @KevinMacKenzie61 Рік тому +7

    Another great video. Loved the way you handled both styles with the TS at the end.

  • @merrycruise328
    @merrycruise328 8 місяців тому +1

    Thank you for such a descriptive tutorial, not even chatGPT could help me with this!! ❤

  • @kaviisuri9997
    @kaviisuri9997 Рік тому +4

    Awesome video!
    One idea, Why not make searchTerm a writable store, and make searchStore a derived store that recomputes filtered values based on searchTerm?
    Basically eliminate the need for manual subscription

    • @Huntabyte
      @Huntabyte  Рік тому

      That's also a great way to handle this!

  • @frankspin9124
    @frankspin9124 Рік тому +6

    Great video. Would love to see a video on building category/tags filters in combination with pagination.

  • @gabrielbrisson6012
    @gabrielbrisson6012 8 місяців тому +1

    Great video, as always!

  • @danielk.9321
    @danielk.9321 Рік тому +2

    You always cover the most useful topics. Thank you 😊

  • @jesper.ordrup
    @jesper.ordrup Рік тому +2

    Super video. And great that you add the typescript boilerplate last. It makes it so much easier to follow.
    (Not a fan of typescript. Using it, but not a fan. At all)

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

      It can be a bit of a pain for small apps, but as the app scales not having that type safety can become a nightmare! I'm glad you liked the flow!

    • @jesper.ordrup
      @jesper.ordrup Рік тому

      @@Huntabyte while true it still makes code look busy. Lots of "annotations" that distracts from the real logic. I kinda like jsdocs as a lightweight approach. Keeping it in comments can make it easier to keep out of sight.
      Funny enough, I come from c# so go figure 😏

  • @adriansanmartin1313
    @adriansanmartin1313 10 місяців тому

    Gracias por siempre tener una respuesta a mis dudas.. ya paso bastante tiempo desde que vi este video, pero hoy le di un repaso. Saludos

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

    This channel has be really helpful, particularly post-data/load changes. From a python dev with almost no js experience, thanks!

    • @Huntabyte
      @Huntabyte  Рік тому

      I'm glad to hear that, you're very welcome!

  • @codewithguillaume
    @codewithguillaume Рік тому

    Hello my friend sorry to say that but I am going to steal this for my next course on Svelte 😂❤ thanks for your work this is amazing!

  • @stor-tech
    @stor-tech Рік тому +1

    Thanks soo much for this, my implementation was alot more complex, but you made my life alot easier. love it

  • @itspaulinamac
    @itspaulinamac Рік тому +3

    Thanks for always explaining everything so well! Great content!

  • @allisterfiend_2112
    @allisterfiend_2112 4 місяці тому

    Nice, tutorial! It would be cool to see you do this same thing using Runes from Svelte 5 so we could see the difference in the amount of work that has to be done.

  • @salahiddinediouri280
    @salahiddinediouri280 Рік тому +2

    This is a great use case, thank you for the video and for the cool explanation

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

    so accessible and helpful! thank you! Really great style.

  • @kbaratyants
    @kbaratyants 10 місяців тому

    Excellent instructional video!
    How can additional filters be incorporated into the application, appearing as additional buttons? For instance, when clicking the button labeled "laptops," only laptop-related items would be displayed, making it easy to locate specific items within the laptops category.

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

    Again an other great video, Thanks for all of your work and your time ! ;)

  • @irreal2
    @irreal2 Рік тому +10

    If you are already "pre-computing" the searchTerm property on each product ahead of time, why not convert it to lower case at that point? Instead, you do a .toLowerCase() each time the search term updates, causing a whole bunch of extra work.

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

    Nice! I learned a new way to search. Thank you! :)

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

    Thank you very much ! I was looking into this

  • @pevey
    @pevey Рік тому

    This is really next level. Great video.

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

    Really great, Thank you for the sveltekit playlist it really help me to practice. Keep update!

  • @omomer3506
    @omomer3506 Рік тому

    Real Noice, I was using the reactive $: inside the component and filtering it out there, basically what you did in the store mine was in the component it self, somehow yours seems cleaner but i am too lazy to update mine 😁

  • @legionsra
    @legionsra Рік тому +2

    Although I like the video. The reason this is working is because the searchHandler is modifying on real time the reference of the object the store is located. No Svelte functionality here and the reason reactivity is working is because Svelte actually deeply watches changes on the object but you should not rely on that. If this was done with primitive values this will never work. I would have created instead a second derived store with data filtered based on a search term and then this is the subscribed store in the results panel. But overall is great

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

      Nobody should ever modify a store directly in a subscribe function. Subscription is meant to be read, not to be written.

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

      Hey thanks for that feedback, if you have discord or could send here - would you mind linking a REPL with an example of this, I’d greatly appreciate it! There’s always a few different ways to accomplish the same thing and I’m always looking for the best ways!

    • @morgo52
      @morgo52 Рік тому

      I was about to reply with the same idea. Since the handler is in implemented in your search file it also doesn't make sense to require the consumer to link this up. The derived store would keep this in the same place and give you the option to have multiple derived stores that can be subbed to depending on if you wanted to provide different filter algorithms. e.g. includesSearchResults, fuzzySearchResults, etc...

    • @legionsra
      @legionsra Рік тому +4

      ​ @Huntabyte I made a simplistic example with all inside page.svelte in 9 lines. But I can give you also all in one single store function stackblitz /edit/github-tnt8vu?file=src/routes/+page.svelte (beware the missing domain)

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

      @@legionsra This was helpful, thanks for sharing!

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

    What font family are you using?! It kinda looks like Fira Code but a little less busy. I want to try it.

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

    Thank you! Great content!

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

    can you explain why a store is useful here vs. a hook? We aren’t using these functions, stores, or filter values anywhere else or across cross components or pages. Just curious on the choice to use a store. Thanks!

    • @Huntabyte
      @Huntabyte  Рік тому

      It’s more so mean to be an example of how you could reuse the same logic throughout the app for various sets of data! Poor explanation for that part 😂

    • @inDefEE
      @inDefEE Рік тому

      @@Huntabyte ahhh ok got it. I do like this for something like that. Another good use case I think would be selecting and filtering items across pagination.
      Thanks for the video and response! I’m learning Svelte right now for my side business and it has been a blast. Your vid’s help a lot!

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

    What browser are you using? Neat to have the tabs on the left side.

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

      Microsoft Edge!

    • @theIbraDev
      @theIbraDev Рік тому

      @@Huntabyte i just edited the css of firefox to get the same layout :D

  • @チョリパン-j4f
    @チョリパン-j4f 10 місяців тому

    yoo thank you for this!

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

    Grato demais !!!!

  • @RiddlerRiddle
    @RiddlerRiddle 7 місяців тому

    is there a limit to data size, can this handle millions of rows of data or is it for something like 1k-2k rows of data?

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

    Nice💙

  • @acharafranklyn5167
    @acharafranklyn5167 Рік тому

    This is what makes svelte far better than react.... For you to implement this n React you would have to use hooks and reducers

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

    Wanna point out that you wouldn't do this in a page.svelte file normally, but rather the page.js or page.server.js file. You don't typically execute functional logic on the view itself.

    • @SeanLazer
      @SeanLazer Рік тому

      Wouldn't that require a roundtrip to the server every time though? If you already have all your data loaded and the collection isn't that large client side filtering is probably the fastest way to handle it. But fair to say that those cases are rarer than cases where you're filtering from a DB or third party API

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

      Yeah, this video isn't covering how to search via a 'search' endpoint - but moreso a way to filter the already loaded data. There are multiple ways to accomplish the same thing, including an even simpler way then I demonstrated here.

  • @Kostyshko
    @Kostyshko 10 місяців тому

    It`s not real, proper types. You should not use any. And what is PropertyKey? It`s indefined