Persistent Managed Caches with Remix Client Loader

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ต.ค. 2024

ความคิดเห็น • 15

  • @sayedhasan4102
    @sayedhasan4102 9 หลายเดือนก่อน +12

    7:42 there's a refresh button to show the latest index db data, it's above the first column :)

  • @kellenbusby
    @kellenbusby 9 หลายเดือนก่อน +6

    Hey great video, Ryan. A really nice demo of clientLoader. I'll have to play around with this. Do you have any plans to make videos or discuss progressive web apps and Remix?

  • @Greybph
    @Greybph 9 หลายเดือนก่อน +1

    Very cool. Gonna have to rewrite some of my logic using Jotai persistent atoms and implement this pattern with the clientLoader instead.

  • @tedogirma
    @tedogirma 9 หลายเดือนก่อน

    this is best feature and it fixs all hydration issue
    Thanks Rayn also it works with defer mode on clientLoader which is nice 🥂🥂🥂

  • @jitujazz123
    @jitujazz123 3 หลายเดือนก่อน

    Thanks for the great tutorial there. Can we send some data from clientLoader to serverLoader when calling the serverLoader function? My serverLoader returns a few things and I want to cache only a piece of that info and not the complete response. It would work if I could send some flag to the serverLoader to not load data from the DB as the localStorage has that data

  • @akshayaurora
    @akshayaurora 7 หลายเดือนก่อน +1

    Don't we need to worry about invalidating the client side cache?

  • @yanchesky
    @yanchesky 9 หลายเดือนก่อน

    Nice series!

  • @Callerooo
    @Callerooo 9 หลายเดือนก่อน

    Is there some convention when to clear this indexDB? I'm thinking it might become very large if the user clicks on a lot of movies?

    • @twitchizle
      @twitchizle 9 หลายเดือนก่อน

      I wouldnt mind that much,

    • @HerrSiering
      @HerrSiering 9 หลายเดือนก่อน +4

      MDN says: "The process by which the browser works out how much space to allocate to web data storage and what to delete when that limit is reached is not simple, and differs between browsers." - so my guess would be that the browser takes care of keeping the size in check. And if it then deletes an item because of this, the code falls back to loading it again from the server. And probably another item is removed then? Anyways, nothing to actively care about because the browser takes over that job for you.

  • @RoufaYouakeem
    @RoufaYouakeem 9 หลายเดือนก่อน

    React query in client loader to manage the cache for us?

  • @BearD1cky
    @BearD1cky 9 หลายเดือนก่อน

    3:50 If Ryan had some defer hooks in serverLoader, what would happen? Can't we let clientLoader to save cache to loaclforage?

    • @tedogirma
      @tedogirma 9 หลายเดือนก่อน

      ya i works fine
      Here is simple sample i have got
      ```
      export async function clientLoader ({ serverLoader }: ClientLoaderFunctionArgs) {
      const key = 'received'
      const cacheData = await localforage.getItem(key)
      if (cacheData) return { received: cacheData }
      localforage.setItem(key, serverLoader())
      return defer({ received: serverLoader() })
      }
      use trycatch to handle incase if there is issue inside serverLoader
      ```
      And Server Loader is
      ```
      export async function loader () {
      return db.received.findMany({
      take: 15,
      where: {
      to: '9153'
      }
      })
      }
      ```
      also use Suspense and Await inside your tsx file i think this what you need ....

    • @ceopaludetto
      @ceopaludetto 5 หลายเดือนก่อน

      Probably he need to await the movie aswell, but he checked if has a defer to properly destructure since you cannot destructure a promise
      let loaderResult = await serverLoader()
      let movie = await loaderResult.movie