6 Stores
This chapter covers
- Defining writable, readable, derived, and custom stores
- Using stores to share data between components
- Using stores in conjunction with JavaScript classes
- Persisting stores
This chapter focuses on using stores to share data between components, regardless of their relationship in the component hierarchy. Stores provide an alternative to using props or context. They hold application state outside any component. Each store holds a single JavaScript value, but the value can be an array or an object, which of course can hold many values.
Svelte supports several kinds of stores.
-
Writable stores allow components to change their data.
-
Readable stores do not allow components to change their data because the store itself ...
Get Svelte and Sapper in Action now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.