How to use Proxy Objects - JavaScript Tutorial

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

КОМЕНТАРІ • 32

  • @ricardopassos1180
    @ricardopassos1180 3 роки тому +6

    I barely understand English, but your way of explaining the Proxy API is by far the best I've found

  • @luisdwq123
    @luisdwq123 3 роки тому +11

    I was having a hard time understanding proxies, your explanation really helped thanks :)

    • @dcode-software
      @dcode-software  3 роки тому +3

      You're welcome and thanks for the Twitter follow!

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

    Awesome, easy and clear. Thank you for the video!

  • @Dan-p7f
    @Dan-p7f 2 роки тому +2

    Thank you so much. You're channel is being very helpful on couple topics for me. Subbed + liked

  • @hanjelly5410
    @hanjelly5410 3 роки тому +3

    Crystal clear and easy to understand!

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

    What are some of the good uses for it? As far as I can think of is default configurations for your app, e.g. default Express configurations like ports, etc. defined in a JSON format.

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

      I wrote a little utility that allows me to perform array-like operations on an object (iterate in loops, push, pop, etc.) Using a proxy to achieve this ended up helping helping me account for unexpected user behaviors (eg. otherwise it's hard to catch a user running a push on what I deem a tuple in a runtime context). That's my little use case from earlier today.
      The world's second most popular typescript framework, VueJS, is also based on proxies. Turns out proxies are really good for setting up guardrails for how people use code, so if you can "prove" that users will write reasonably safe code, you can become more aggressive about state-management techniques. Vue's state model is better at surgical updates than say, React, because of the library's extensive use of Proxies (among other architectural innovations).
      Hope you found this response enlightening. Best wishes mate.
      - Oz.

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

    Good explanation. Thanks.

  • @yinonelbaz5309
    @yinonelbaz5309 2 роки тому

    Crystal clear and easy to understand

  • @nathoud7166
    @nathoud7166 2 роки тому +1

    very clear and understanbable 👍

  • @jmmmmmmmmmk
    @jmmmmmmmmmk 8 місяців тому

    Thx good video

  • @abhishekmg2451
    @abhishekmg2451 2 роки тому

    Awesome video !!! very clear

  • @dangerdoctor920
    @dangerdoctor920 2 роки тому +1

    I wrote exactly like you did but it gives an error
    Uncaught TypeError: 'set' on proxy: trap returned falsish for property 'difficulty' on line 309

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

    Thanks!

  • @rafaelmrantunes
    @rafaelmrantunes 3 роки тому

    Very nice video. Btw, which font is this?

    • @gatty.
      @gatty. 3 роки тому

      Might be Open Sans

  • @ashiqdey
    @ashiqdey 2 роки тому

    awesome man

  • @intykatgames
    @intykatgames 2 роки тому

    METATABLES IN JAVASCRIPT!!! HECK YEAHHHH

  • @eren_korkmaz
    @eren_korkmaz 2 роки тому

    best. thank you

  • @alex-dk2rj
    @alex-dk2rj 2 роки тому

    Proxies underrated

  • @dhruvshah7783
    @dhruvshah7783 2 роки тому

    Nice!

  • @FordExplorer-rm6ew
    @FordExplorer-rm6ew 4 роки тому

    Where to store secrets?
    like a keys.js file?, ideal / best practices?
    For production mostly

  • @troooooper100
    @troooooper100 4 роки тому +3

    why not just use class with private fields?

    • @erykczajkowski8226
      @erykczajkowski8226 3 роки тому

      My guess is this proxy thingy seems to have more 'traps' than class, which has just two - set and get?

    • @اشکانمحمدی-ز1ث
      @اشکانمحمدی-ز1ث 2 роки тому +3

      I believe that the use case demonstrated in this video was not a good example of a proxy. The real use case is when you want to perform some extra work behind the scenes that is not directly related to the object itself. For example you might want to save the game settings object in a SQL db, Redis cache, document cookies or local storage or etc... You might want to listen to the changes in the game settings properties and send them over an external API to sync the changes across the player's devices and so on and so forth ...
      None of these tasks are directly related to the gameSettings object. The purpose of the game settings object is to just represent the settings and control how you set or get them, it's not meant to have the implementation logic for syncing settings across devices or saving them to a storage. Proxies provide a better way to handle these situations

  • @BroccoliColdbrew
    @BroccoliColdbrew 8 місяців тому

    Like this video❤

  • @souravhemachandran5298
    @souravhemachandran5298 3 роки тому

    Wow, guy just types with his mouse

  • @fatkhurohmana5937
    @fatkhurohmana5937 6 місяців тому

    useImmer bring me here

  • @lawaldare
    @lawaldare 4 роки тому

    First comment!!!👊🏿