-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #390 from Shopify/fd-vite-rsc-request-provider
Combine SSR and RSC responses + Request Provider
- Loading branch information
Showing
19 changed files
with
305 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import runAsync from './async-stuff'; | ||
import CAsync2 from './CAsync2.server'; | ||
|
||
export default function CAsync1() { | ||
const result = runAsync('CAsync1'); | ||
|
||
return ( | ||
<div> | ||
c-async-1 {String(result)} | ||
<div> | ||
<CAsync2></CAsync2> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import runAsync from './async-stuff'; | ||
|
||
export default function CAsync2() { | ||
const result = runAsync('CAsync2'); | ||
|
||
return <div>c-async-2 {String(result)}</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import {useServerRequest} from '@shopify/hydrogen'; | ||
|
||
export default function (key, ms = 1000) { | ||
const request = useServerRequest(); | ||
const cache = request.context.cache; | ||
|
||
const cached = cache.get(key); | ||
|
||
if (cached) { | ||
if (cached instanceof Promise) { | ||
throw cached; | ||
} | ||
|
||
return cached; | ||
} | ||
|
||
console.log('---FETCHING', key, request?.id || 'undefined'); | ||
const promise = new Promise((r) => setTimeout(() => r(true), ms)); | ||
cache.set(key, promise); | ||
promise.then((result) => { | ||
cache.set(key, result); | ||
}); | ||
|
||
throw promise; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
packages/hydrogen/src/foundation/RenderCacheProvider/RenderCacheContext.tsx
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
packages/hydrogen/src/foundation/RenderCacheProvider/RenderCacheProvider.tsx
This file was deleted.
Oops, something went wrong.
50 changes: 0 additions & 50 deletions
50
packages/hydrogen/src/foundation/RenderCacheProvider/hook.ts
This file was deleted.
Oops, something went wrong.
48 changes: 0 additions & 48 deletions
48
packages/hydrogen/src/foundation/RenderCacheProvider/hook.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.