Skip to content

Is it possible to create an SSE handler without a generator? #1309

@szagi3891

Description

@szagi3891

Describe the feature

    class SourceOfEvents {
        async process(id: string, emit: (event) => void) {
            for (let i=0; i<100; i++) {
                emit({
                    message: `event id=${id} count: ${i}`
                });

                await timeout(1000);
            }
        }
    }

    const sourceOfEvents = new SourceOfEvents();
    test: os
        .input(z.obiect({
            id: z.string(),
        }))
        .handler(async ({ input, emit }) => {
            await sourceOfEvents.process(input.id, emit);
            //end of stream SSE
        })

I would like to be able to create an SSE handler without generators.
In my application, I would like to have an object or function that allows sending new events directly to an SSE stream (without generators).

Additional information

  • Would you be willing to help implement this feature?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions