edges-svelte 0.5.4 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +34 -4
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Edge-S
1
+ # EdgeS
2
2
 
3
3
  ### A blazing-fast, extremely lightweight and SSR-friendly store for Svelte.
4
4
 
5
- **Edge-S** brings seamless, per-request state management to Svelte apps — fully reactive, server-aware, and serialization-safe by default.
5
+ **EdgeS** brings seamless, per-request state management to Svelte apps — fully reactive, server-aware, and serialization-safe by default.
6
6
 
7
7
  No context boilerplate. No hydration headaches. Just drop-in SSR-compatible state primitives with built-in support for client-side reactivity and server-side isolation.
8
8
 
@@ -26,7 +26,7 @@ npm install edges-svelte
26
26
 
27
27
  ## Setup
28
28
 
29
- To enable **Edge-S**, wrap your SvelteKit `handle` hook and serialize the state in `transformPageChunks`:
29
+ To enable **EdgeS**, wrap your SvelteKit `handle` hook and serialize the state in `transformPageChunks`:
30
30
 
31
31
  ```ts
32
32
  // hooks.server.ts
@@ -97,6 +97,36 @@ const myProvider = createProvider({
97
97
 
98
98
  ---
99
99
 
100
+ ## Provider Caching with `cacheKey`
101
+
102
+ To improve performance and avoid redundant computations, **EdgeS** supports caching providers by a unique `cacheKey`.
103
+
104
+ ### What is `cacheKey`?
105
+
106
+ - A `cacheKey` is a string uniquely identifying a specific provider invocation.
107
+ - It enables **caching the result of the provider’s factory function**
108
+ - Prevents repeated calls to the same provider with identical parameters.
109
+ With caching:
110
+
111
+ - The provider is called **only once per unique `cacheKey`** within a request.
112
+ - Subsequent calls with the same key return the cached result instantly.
113
+
114
+ ### How to use `cacheKey`
115
+
116
+ ```ts
117
+ import { createProvider } from 'edges-svelte';
118
+
119
+ const myProvider = createProvider({
120
+ cacheKey: (params) => params.userId,
121
+ factory: ({ createState }, params) => {
122
+ const userData = createState('userData', () => fetchUserData(params.userId));
123
+ return { userData };
124
+ }
125
+ });
126
+ ```
127
+
128
+ ---
129
+
100
130
  ## Core Concepts
101
131
 
102
132
  ### SSR-safe state access
@@ -213,7 +243,7 @@ type EdgesHandle = (
213
243
 
214
244
  ### Why not just use `writable, derived`?
215
245
 
216
- Because `writable` and `derived` shares state between requests when used on the server. That means users could leak state into each other’s responses. **Edge-S** solves that by isolating state per request.
246
+ Because `writable` and `derived` shares state between requests when used on the server. That means users could leak state into each other’s responses. **EdgeS** solves that by isolating state per request.
217
247
 
218
248
  ### Difference between `createState` and `createRawState`
219
249
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edges-svelte",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "license": "MIT",
5
5
  "author": "Pixel1917",
6
6
  "description": "A blazing-fast, extremely lightweight and SSR-friendly store for Svelte",