How to use Proxy Objects - JavaScript Tutorial

Поделиться
HTML-код
  • Опубликовано: 24 окт 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!

  • @yinonelbaz5309
    @yinonelbaz5309 2 года назад

    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.

  • @nathoud7166
    @nathoud7166 3 года назад +1

    very clear and understanbable 👍

  • @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

  • @oleksandrparnekov1371
    @oleksandrparnekov1371 Год назад

    Good explanation. Thanks.

  • @jmmmmmmmmmk
    @jmmmmmmmmmk 9 месяцев назад

    Thx good video

  • @jeetanshusrivastava2155
    @jeetanshusrivastava2155 Год назад

    Thanks!

  • @abhishekmg2451
    @abhishekmg2451 2 года назад

    Awesome video !!! very clear

  • @alex-dk2rj
    @alex-dk2rj 2 года назад

    Proxies underrated

  • @ashiqdey
    @ashiqdey 2 года назад

    awesome man

  • @rafaelmrantunes
    @rafaelmrantunes 3 года назад

    Very nice video. Btw, which font is this?

    • @gatty.
      @gatty. 3 года назад

      Might be Open Sans

  • @eren_korkmaz
    @eren_korkmaz 2 года назад

    best. thank you

  • @intykatgames
    @intykatgames 2 года назад

    METATABLES IN JAVASCRIPT!!! HECK YEAHHHH

  • @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

  • @dhruvshah7783
    @dhruvshah7783 2 года назад

    Nice!

  • @BroccoliColdbrew
    @BroccoliColdbrew 9 месяцев назад

    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!!!👊🏿