Actual use case for JavaScript PROXY!

  Рет қаралды 12,631

Kevin Ghadyani - JavaScript

Kevin Ghadyani - JavaScript

Күн бұрын

Use cases for JavaScript proxies is one of the things most people aren't familiar with doing, but it's a super powerful tool if you know how to use them.
I show you a way I'm using proxies today at work for deprecating object properties that aren't functions.

Пікірлер: 34
@thatguyintech
@thatguyintech 2 ай бұрын
Really appreciated the progressive code snippets and explanations at each stage. Super useful!
@etinosaizekor6533
@etinosaizekor6533 17 күн бұрын
Wow. The example is so useful and make it easy to understand! Great video
@danser_theplayer01
@danser_theplayer01 5 күн бұрын
That's exactly what I need. I have a small program which saves an array into localStorage to be inserted into a class every time you reopen the page. Unfortunately the program needs to be rewritten and the array structure and name changed, which means unless I do somehing clever - the users saved progress will break.
@luk318
@luk318 Ай бұрын
All other videos I watched about object were like reading wikipedia or witch nonsense examples. Real life examples are always the best. Thank you
@StefanStefanov-uv2db
@StefanStefanov-uv2db 8 ай бұрын
Very nice tutorial! Definitely an underrated channel..
@atanasatanasov859
@atanasatanasov859 29 күн бұрын
Very nice. Thank you
@SzybkieSzociki
@SzybkieSzociki 4 ай бұрын
First js vido in my life that i actually enjoyd.
@AJMichels
@AJMichels 2 ай бұрын
Nice video. It is inaccurate to say the original commits are “deleted” when performing a rebase. They still exist and can be accessed and even recovered if you know their original hashes. They do end up in an orphaned state and can be “cleaned up” under certain circumstances in the future.
@TomDoesTech
@TomDoesTech 2 жыл бұрын
Great video! I've found of a use-case for proxies before, but this seems really useful.
@soumyamondal
@soumyamondal 5 ай бұрын
I'll definitely share this one, truly amazing content.
@Jessyco
@Jessyco 4 ай бұрын
This was a great example and use case, thank you!
@CSCoreDecoded
@CSCoreDecoded Жыл бұрын
Awesome video Kevin! It is a very helpful use-case. Thank you so much for this
@THEShAdOwHFV
@THEShAdOwHFV 6 ай бұрын
Great video, thanks for the info!
@williamragstad
@williamragstad 2 жыл бұрын
Amazing video, you just earned yourself a new subscriber!
@mayank_m_jain_1160
@mayank_m_jain_1160 6 ай бұрын
Great Video ! Thanks SIr !
@TheArmanist
@TheArmanist 7 ай бұрын
Great explanation, thanks
@justAbeautifulSoul409
@justAbeautifulSoul409 2 ай бұрын
ONE OF THE BESTEXPLANATION THABK YOU❤
@igboanugwocollins4452
@igboanugwocollins4452 Жыл бұрын
This is super helpful, thank you
@user-hd7vt8rd7v
@user-hd7vt8rd7v 10 ай бұрын
Great Vedio, very helpful
@jmmmmmmmmmk
@jmmmmmmmmmk 7 ай бұрын
Thx very good video
@rotvein4629
@rotvein4629 7 ай бұрын
For me it seems more obvious and simple just to add to the `fontSized` object a property `__proto__: legacyFontSizes`. Then `extreaLagre` and `extraSmall` won't appear by iteration, but not break the legacy code as e.g. with an attempt of getting `extraSmall` the `gigantic` will be returned. I still find your video very clear-cut and helpful, thank you! But can you please answer if in this particular case my solution is inferior to the approach with `Proxy`?
@KevinGhadyani
@KevinGhadyani 7 ай бұрын
That's a great idea and a lot simpler! Personally, I wouldn't depend on proto as that's like black magic; unless I'm missing the mark. It's got that code smell. You also need to check for existing values first too. Hmm 🤔.
@mgrycz
@mgrycz Жыл бұрын
Can I ask what font do you use in the video?
@KevinGhadyani
@KevinGhadyani Жыл бұрын
For the code of thumbnail? The code is Victor Mono, but I'm not exactly sure what it was in this video.
@FarhanAli-wc3hs
@FarhanAli-wc3hs 10 күн бұрын
Playback speed: 0.75x Thank me later.
@KevinGhadyani
@KevinGhadyani 10 күн бұрын
😂
@lborate3543
@lborate3543 Жыл бұрын
You can literally just set the forntsizes extralarge to the new translation. The proxy isnt doing anything magical. FontSizes.ExtraLarge.Value When you have to update your code for depricated values you can just set the value from the object. What is it that a proxy can do that cant be done in a simple return value or if then statements?
@KevinGhadyani
@KevinGhadyani Жыл бұрын
If people are using your library, but you have an object and not a function, this is a way of adding code to an object that isn't a function. Most times, you don't want breaking changes in a library, and proxies can make these changes non-breaking.
@lborate3543
@lborate3543 Жыл бұрын
@Kevin Ghadyani - JavaScript oh you're using it inside a library. I was thinking this was all inside the same class. I guess if it's in a library then it probably is more useful as the Contractor is created for 100's of users.
@injSrc
@injSrc Жыл бұрын
Why we can't do something like const FontSize = { ....... tiny: tiny, get extraSmall() { console.warn('warning...') return this.tiny } ....... }
@KevinGhadyani
@KevinGhadyani Жыл бұрын
Does that work? I've only ever done that with proxies and Object.defineProperty.
@animeshkumar9593
@animeshkumar9593 Жыл бұрын
I feel this should work, but with these caveats: 1. The more the number of deprecated keys, the larger the object grows as you need to define getters/setters for all the deprecated keys. Proxy does it in one place. 2. Object.keys(FontSize) would still return the deprecated keys. While you can mark the deprecated keys as non-enumerable, you would need to do that for each and every key.
@KevinGhadyani
@KevinGhadyani Жыл бұрын
I had a live stream where I converted object-based to proxies, and it's like you said, proxies scale better.
The Power of JS Generators by Anjana Vakil
36:10
JSConf
Рет қаралды 164 М.
JavaScript Proxies
22:54
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 11 М.
Look at two different videos 😁 @karina-kola
00:11
Andrey Grechka
Рет қаралды 15 МЛН
SPONGEBOB POWER-UPS IN BRAWL STARS!!!
08:35
Brawl Stars
Рет қаралды 17 МЛН
Challenge matching picture with Alfredo Larin family! 😁
00:21
BigSchool
Рет қаралды 43 МЛН
If Barbie came to life! 💝
00:37
Meow-some! Reacts
Рет қаралды 75 МЛН
9 JavaScript Features You’ve Never Used
19:36
Conner Ardman
Рет қаралды 28 М.
The Most Important Skill You Never Learned
34:56
Web Dev Simplified
Рет қаралды 195 М.
Javascript Design Patterns #6 - Proxy Pattern
12:11
DevSage
Рет қаралды 27 М.
Что такое ПРОКСИ в JavaScript (Proxy)
10:11
Веб-разработка - DevMagazine
Рет қаралды 10 М.
Don't Use Polly in .NET Directly. Use this instead!
14:58
Nick Chapsas
Рет қаралды 57 М.
You are using useFetch WRONG! (I hope you don't)
11:14
Alexander Lichter
Рет қаралды 26 М.
Proxy Pattern in JavaScript
18:35
Code with Ahsan
Рет қаралды 1 М.
Node.js is a serious thing now… (2023)
8:18
Code With Ryan
Рет қаралды 642 М.
Look at two different videos 😁 @karina-kola
00:11
Andrey Grechka
Рет қаралды 15 МЛН