Custom Svelte Store: Higher Order Store
---
In this video, I am going to show how to use functional programming concept, higher-order functions into Svelte stores. And I am calling it, higher-order store.
Higher order store is a function that takes in a store as an argument, and returns a new store. The returned store is derived from the input store, but with enhanced abilities.
For example, a `throttled` higher-order store takes in a store and returns a `throttled` version of the store. The store value is updated in a throttled manner.
Writing the `throttle` logic as a higher-order store allow us to easily reuse it, by applying `throttle` to any store that we want to throttle.
In the video, I’ve shown other examples of higher-order store, such as:
- throttle
- debounce
- readonly
- spring
---
💻 REPL:
📚 Related Resources
DOM Events as Svelte Store
tweened() Svelte store
The Difference Bet