Тёмный

Actual use case for JavaScript PROXY! 

Kevin Ghadyani - JavaScript
Подписаться 2,2 тыс.
Просмотров 11 тыс.
50% 1

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.

Опубликовано:

 

21 сен 2021

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 26   
@justAbeautifulSoul409
@justAbeautifulSoul409 8 часов назад
ONE OF THE BESTEXPLANATION THABK YOU❤
@SzybkieSzociki
@SzybkieSzociki Месяц назад
First js vido in my life that i actually enjoyd.
@DevCoder
@DevCoder 10 месяцев назад
Awesome video Kevin! It is a very helpful use-case. Thank you so much for this
@TomDoesTech
@TomDoesTech 2 года назад
Great video! I've found of a use-case for proxies before, but this seems really useful.
@StefanStefanov-uv2db
@StefanStefanov-uv2db 6 месяцев назад
Very nice tutorial! Definitely an underrated channel..
@Jessyco
@Jessyco 2 месяца назад
This was a great example and use case, thank you!
@soumyamondal
@soumyamondal 2 месяца назад
I'll definitely share this one, truly amazing content.
@AJMichels
@AJMichels 9 дней назад
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.
@igboanugwocollins4452
@igboanugwocollins4452 Год назад
This is super helpful, thank you
@williamragstad
@williamragstad 2 года назад
Amazing video, you just earned yourself a new subscriber!
@THEShAdOwHFV
@THEShAdOwHFV 4 месяца назад
Great video, thanks for the info!
@TheArmanist
@TheArmanist 5 месяцев назад
Great explanation, thanks
@mayank_m_jain_1160
@mayank_m_jain_1160 4 месяца назад
Great Video ! Thanks SIr !
@user-hd7vt8rd7v
@user-hd7vt8rd7v 8 месяцев назад
Great Vedio, very helpful
@jmmmmmmmmmk
@jmmmmmmmmmk 5 месяцев назад
Thx very good video
@rotvein4629
@rotvein4629 5 месяцев назад
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 5 месяцев назад
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 10 месяцев назад
Can I ask what font do you use in the video?
@KevinGhadyani
@KevinGhadyani 10 месяцев назад
For the code of thumbnail? The code is Victor Mono, but I'm not exactly sure what it was in this video.
@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.
Далее
9 JavaScript Features You’ve Never Used
19:36
Просмотров 24 тыс.
JavaScript Proxies
22:54
Просмотров 11 тыс.
ЭКСПРЕСС разбор стиралки
00:39
Просмотров 732 тыс.
Что такое ПРОКСИ в JavaScript (Proxy)
10:11
Javascript Design Patterns #6 - Proxy Pattern
12:11
Просмотров 27 тыс.
A Practical Guide to JavaScript Proxy Objects
14:19
Просмотров 6 тыс.
So You Think You Know Git - FOSDEM 2024
47:00
Просмотров 992 тыс.
Why Signals Are Better Than React Hooks
16:30
Просмотров 454 тыс.
The Power of JS Generators by Anjana Vakil
36:10
Просмотров 161 тыс.