Undo / Redo with Svelte Store
Let's take a look at how we can implement a Svelte store with undo / redo ability
Svelte store aside, if you want to implement undo / redo / time travel of a data, there's generally 2 approaches:
1. storing a history of actions, undo/redo becomes replaying / rewind the actions
2. storing a history of snapshots of your data, undo / redo becomes reverting to the snapshot of your data
To bring it back to svelte store, i have a concept called higher-order store, which is a function to create a new store out of existing store, with enhanced ability. This allow us to add undo / redo ability to either writable, tweened, or spring store !
We are going to explore both approaches.
Introduction 00:00
The set up 00:30
The 2 approaches 01:48
Approach 1 - History of actions 05:34
action creator 12:20
Implementing the history of actions 15:43
Redoing the action 19:46
Summary of approach 1 30:07
Approach 2 - History of snapshots 32:49
Svelte store with mutable objects 38:53
Cloning objects into snapshots 44:20
Update Svelte store immutably 52:45
Immutability with Immer 55:00
Summary of approach 2 59:20
---
💻 REPL: https://svelte.dev/repl/4126151f40214bb985f42a80166c7ec3?version=3.38.3
📚 Related Resources
get() https://svelte.dev/docs#get
Immer: Using produce https://immerjs.github.io/immer/produce
Immer for immutable Svelte store https://youtu.be/mHqCAEUkiWs
Higher Order store https://youtu.be/p1aPfVyZ1IY
🥰 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
Видео Undo / Redo with Svelte Store канала lihautan
Svelte store aside, if you want to implement undo / redo / time travel of a data, there's generally 2 approaches:
1. storing a history of actions, undo/redo becomes replaying / rewind the actions
2. storing a history of snapshots of your data, undo / redo becomes reverting to the snapshot of your data
To bring it back to svelte store, i have a concept called higher-order store, which is a function to create a new store out of existing store, with enhanced ability. This allow us to add undo / redo ability to either writable, tweened, or spring store !
We are going to explore both approaches.
Introduction 00:00
The set up 00:30
The 2 approaches 01:48
Approach 1 - History of actions 05:34
action creator 12:20
Implementing the history of actions 15:43
Redoing the action 19:46
Summary of approach 1 30:07
Approach 2 - History of snapshots 32:49
Svelte store with mutable objects 38:53
Cloning objects into snapshots 44:20
Update Svelte store immutably 52:45
Immutability with Immer 55:00
Summary of approach 2 59:20
---
💻 REPL: https://svelte.dev/repl/4126151f40214bb985f42a80166c7ec3?version=3.38.3
📚 Related Resources
get() https://svelte.dev/docs#get
Immer: Using produce https://immerjs.github.io/immer/produce
Immer for immutable Svelte store https://youtu.be/mHqCAEUkiWs
Higher Order store https://youtu.be/p1aPfVyZ1IY
🥰 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
Видео Undo / Redo with Svelte Store канала lihautan
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
![Svelte components communicate without store / props / context?](https://i.ytimg.com/vi/lEBvoEmbpsU/default.jpg)
![How to actually pass Svelte component through props?](https://i.ytimg.com/vi/2nohdjOFEnQ/default.jpg)
![Why I picked SVELTE instead of React or Vue](https://i.ytimg.com/vi/vbLRLMEUwlU/default.jpg)
![Fixing Svelte issue #4767 - meta tag get svelte-xxx classname with :root](https://i.ytimg.com/vi/YvVr3sIVs7s/default.jpg)
![How Science is Taking the Luck out of Gambling - with Adam Kucharski](https://i.ytimg.com/vi/658xlubwnDc/default.jpg)
![Future of Svelte with Alexander Esselink](https://i.ytimg.com/vi/JRF2yi69ZII/default.jpg)
![Fixing issue #5415 - Error when using animate flip if there is no space in front of each block](https://i.ytimg.com/vi/IyCFv8_mvk8/default.jpg)
![Fixing issue #6433 - Incorrect select value when using spread](https://i.ytimg.com/vi/AijybU_mU3Q/default.jpg)
![The Insane Biology of: The Octopus](https://i.ytimg.com/vi/mFP_AjJeP-M/default.jpg)
![Fixing issue #4551 - input value 0 omitted in SSR rendered HTML](https://i.ytimg.com/vi/ugQ0w-ykuOM/default.jpg)
![Custom Svelte Store: derived() Svelte store](https://i.ytimg.com/vi/i6wdD5mRUkc/default.jpg)
![Sveltekit Crash Course - Svelte Typescript - Getting started with Sveltekit Endpoints](https://i.ytimg.com/vi/6oDSwcZPbxA/default.jpg)
![Svelte Store: 3 tips to manage complex Svelte store](https://i.ytimg.com/vi/qtxG-aoXXCM/default.jpg)
![How to use Svelte component inside a React app?](https://i.ytimg.com/vi/6MI9mirMh6w/default.jpg)
![Mathematics is the queen of Sciences](https://i.ytimg.com/vi/8mve0UoSxTo/default.jpg)
![Custom Svelte Store: Higher Order Store](https://i.ytimg.com/vi/p1aPfVyZ1IY/default.jpg)
![Get Started with Svelte and SvelteKit](https://i.ytimg.com/vi/fOD_3iSiwTQ/default.jpg)
![Supabase & Sveltekit - Setup (Part 1)](https://i.ytimg.com/vi/j4AV2Liojk0/default.jpg)
![Svelte Tutorial for Beginners - Attaching events listeners in Svelte](https://i.ytimg.com/vi/pbGe5F0Kyi8/default.jpg)
![Svelte Store: The Introduction](https://i.ytimg.com/vi/QjMl4usaKGA/default.jpg)