mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
17 lines
341 B
JavaScript
17 lines
341 B
JavaScript
export function createStreamingData() {
|
|
let result
|
|
let promise
|
|
function Data({ children, duration = 500 }) {
|
|
if (result) return result
|
|
if (!promise)
|
|
promise = new Promise((res) => {
|
|
setTimeout(() => {
|
|
result = children
|
|
res()
|
|
}, duration)
|
|
})
|
|
throw promise
|
|
}
|
|
return Data
|
|
}
|