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(js/core): added a way to run actions with side-channel data and streaming #1375

Merged
merged 2 commits into from
Nov 26, 2024

Conversation

pavelgj
Copy link
Collaborator

@pavelgj pavelgj commented Nov 22, 2024

    const act = action(
      {
        name: 'foo',
        inputSchema: z.string(),
        outputSchema: z.number(),
      },
      async (input, { sendChunk, context }) => {
        checkAuth(context);
        sendChunk(1);
        sendChunk(2);
        sendChunk(3);
        return input.length;
      }
    );

    const chunks: any[] = [];
    await act('1234', {
      context: { user: 'pavel' },
      onChunk: (c) => chunks.push(c),
    });

Checklist (if applicable):

  • Tested (manually, unit tested, etc.)

@pavelgj pavelgj requested review from mbleigh and apascal07 November 22, 2024 02:19
@pavelgj pavelgj requested a review from apascal07 November 25, 2024 14:25
@pavelgj pavelgj merged commit f4261f9 into main Nov 26, 2024
4 checks passed
@pavelgj pavelgj deleted the pj/actionContextAndStreaming branch November 26, 2024 17:45
pavelgj added a commit that referenced this pull request Nov 30, 2024
pavelgj added a commit that referenced this pull request Nov 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants