Custom Svelte Store: Immer for Immutable Svelte store
In this video, we are going to take a look at how we can make Svelte store immutable using Immer.
Immer allow us to work on immutable state in a more convenient way.
Changes are applied to the draft, which is a proxy of the state, which then produces the next state.
We will explore how we can create 2 stores, the draft store and the state store, which we can make changes directly to the draft store, and see the changes reflected on the state store.
Immer optimises the immutable state data structure, if the sub object is not changed, it will still maintain the same reference. Only part of the state object that has changed gets updated.
This bring us the opportunity to optimise the subscriber by using the derived store, to derive the substate into a new store.
Introduction 00:00
Looking at Immer doc 00:49
Using produce 02:50
Create the Immer Svelte Store 05:05
Debouncing the changes 12:30
Benefits of using Immer with Svelte 15:45
Deriving from the Immer store 17:50
svelte options immutable 21:04
Implementing undo using patches 24:33
💻 REPL: https://svelte.dev/repl/a8cd6cc371604d44902f01bd18fe29a2
📚 Related Resources
- Tutorials https://svelte.dev/tutorial/custom-stores
- Immer https://immerjs.github.io/immer/
🥰 Support me https://www.buymeacoffee.com/lihautan
🔗 Want to learn more from me? Check out these links:
Twitter: https://twitter.com/lihautan
Blog: https://lihautan.com/
Newsletter: https://lihautan.com/newsletter
#svelte #sveltestore
Thanks for watching 🥰 -- with love, Li Hau
Видео Custom Svelte Store: Immer for Immutable Svelte store канала lihautan
Immer allow us to work on immutable state in a more convenient way.
Changes are applied to the draft, which is a proxy of the state, which then produces the next state.
We will explore how we can create 2 stores, the draft store and the state store, which we can make changes directly to the draft store, and see the changes reflected on the state store.
Immer optimises the immutable state data structure, if the sub object is not changed, it will still maintain the same reference. Only part of the state object that has changed gets updated.
This bring us the opportunity to optimise the subscriber by using the derived store, to derive the substate into a new store.
Introduction 00:00
Looking at Immer doc 00:49
Using produce 02:50
Create the Immer Svelte Store 05:05
Debouncing the changes 12:30
Benefits of using Immer with Svelte 15:45
Deriving from the Immer store 17:50
svelte options immutable 21:04
Implementing undo using patches 24:33
💻 REPL: https://svelte.dev/repl/a8cd6cc371604d44902f01bd18fe29a2
📚 Related Resources
- Tutorials https://svelte.dev/tutorial/custom-stores
- Immer https://immerjs.github.io/immer/
🥰 Support me https://www.buymeacoffee.com/lihautan
🔗 Want to learn more from me? Check out these links:
Twitter: https://twitter.com/lihautan
Blog: https://lihautan.com/
Newsletter: https://lihautan.com/newsletter
#svelte #sveltestore
Thanks for watching 🥰 -- with love, Li Hau
Видео Custom Svelte Store: Immer for Immutable Svelte store канала lihautan
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
![Custom Svelte Store: DOM Events as Svelte store](https://i.ytimg.com/vi/Aq-hZhX2vfU/default.jpg)
![What is Client-Side Rendering (CSR) and Server-side Rendering (SSR)?](https://i.ytimg.com/vi/RMdHNoT6Pdk/default.jpg)
![Building vite-plugin-svelte-inspector](https://i.ytimg.com/vi/udYB24IMtsY/default.jpg)
![[Svelte Talks] Quick Svelte Internationalization (i18n) — Dr Matthias Stahl](https://i.ytimg.com/vi/PqX6j7Ma0DU/default.jpg)
![Svelte Tutorial for Beginners - Infinite List](https://i.ytimg.com/vi/eBBz40UGxWw/default.jpg)
![Loading data in layout and stuff in SvelteKit](https://i.ytimg.com/vi/2EQpQhz30yY/default.jpg)
![SvelteKit Endpoints](https://i.ytimg.com/vi/FSCUj7DgfUE/default.jpg)
![Debugging SvelteKit endpoints and load function using the debugger](https://i.ytimg.com/vi/ubeOpB9FlZE/default.jpg)
![What is Hydration?](https://i.ytimg.com/vi/D46aT3mx9LU/default.jpg)
![SvelteKit $app/stores](https://i.ytimg.com/vi/gBPhr1xbgaQ/default.jpg)
![SvelteKit Layout](https://i.ytimg.com/vi/I0GZKEh1hE8/default.jpg)
![SvelteKit Endpoints Examples](https://i.ytimg.com/vi/rHckl5bZtpE/default.jpg)
![Svelte Action Examples: use:tooltip](https://i.ytimg.com/vi/0GqIoo66i0g/default.jpg)
![Resolving](https://i.ytimg.com/vi/DADB02OLgVo/default.jpg)
![Loading Data in SvelteKit](https://i.ytimg.com/vi/El4B-2fOHCA/default.jpg)
![Invalidating data](https://i.ytimg.com/vi/0gPqjfRprO4/default.jpg)
![Using Immer with Reducers and React Hooks](https://i.ytimg.com/vi/FmKjwh34Rn8/default.jpg)
![How to build svelte components & use them in React, Angular and Vue](https://i.ytimg.com/vi/RbTM785zhG4/default.jpg)
![Svelte Society Day 2020: Jakob Rosenberg: Routify Presentation](https://i.ytimg.com/vi/3RXqJGZUxy4/default.jpg)
![An intro to Svelte with John Papa](https://i.ytimg.com/vi/l38uRsg81ok/default.jpg)