Skip to content

Is streaming data possible? #1610

@sourcx

Description

@sourcx

Hi,

Hopefully this is the correct place to ask. I'm trying to figure out of I can use this library to stream data but I cannot get it to work yet.

My dotnet backend example that gets converted to Swagger:

[HttpGet("Stream")]
public async IAsyncEnumerable<Thing> GetPropertiesStreaming(CancellationToken cancellationToken)
{
    for (int i = 0; i < 10; i++)
    {
        var stuff = GetStuff(cancellationToken);
        yield return new Thing(i, stuff);
    }
}

My JS code in which I want to iterate over a readable stream:

const res = await ThingsService.getStream() 
for (const thing of res) {
  yield thing 
}

In this case res is of type Thing[] but I want it to be something like ReadableStream<Uint8Array>. Is there any way to achieve this because in this case it waits for all data to be returned at once.

Cheers,
sourcx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions