Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: <SSRStream> #1206

Merged
merged 3 commits into from
Sep 6, 2022
Merged

feat: <SSRStream> #1206

merged 3 commits into from
Sep 6, 2022

Conversation

manucorporat
Copy link
Contributor

@manucorporat manucorporat commented Sep 6, 2022

import { component$, SSRStream } from '@builder.io/qwik';

export function delay(time: number) {
  return new Promise<void>((resolve) => {
    setTimeout(() => resolve(), time);
  });
}

export const Streaming = component$(() => {
  return (
    <div>
      <ul>
        <SSRStream>
          {async function* () {
            for (let i = 0; i < 5; i++) {
              yield <li>yield: {i}</li>;
              await delay(100);
            }
          }}
        </SSRStream>
      </ul>

      <ol>
        <SSRStream>
          {async function (stream) {
            for (let i = 0; i < 10; i++) {
              stream.write(`<li>raw: ${i}</li>`);
              await delay(100);
            }
          }}
        </SSRStream>
      </ol>
    </div>
  );
});

https://www.loom.com/share/4d5814760cf0441bb12a76b101a24518

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Sep 6, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9e1a935
Status: ✅  Deploy successful!
Preview URL: https://00d01d38.qwik-docs.pages.dev
Branch Preview URL: https://ssr-stream-api.qwik-docs.pages.dev

View logs

@manucorporat manucorporat enabled auto-merge (squash) September 6, 2022 11:11
@manucorporat manucorporat merged commit ce48fec into main Sep 6, 2022
@manucorporat manucorporat deleted the ssr-stream-api branch September 6, 2022 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant