Curiosity
Two-column slide showing C# code snippet and rendered UI with ticket cards and connectors.

Calling your endpoints from the UI

Use Mosaik.API.Endpoints.CallAsync to call any custom endpoint. Wrap it in Defer to handle the async rendering cleanly.


// Define your request/response types (shared with the endpoint)
class SimilarRequest  { public string Query { get; set; } }
class TicketSummary   { public string Id { get; set; } public string Subject { get; set; } }

// Render a list of similar tickets
VStack().Children(
    TextBlock("Similar tickets").SemiBold(),
    Defer(async () =>
    {
        var results = await Mosaik.API.Endpoints
            .CallAsync<SimilarRequest, TicketSummary[]>(
                "similar-tickets",
                new SimilarRequest { Query = currentTicket.Body });

        return VStack().Children(
            results.Select(t =>
                Card().Children(
                    TextBlock(t.Subject),
                    TextBlock(t.Id).Small().Muted()
                )
            )
        );
    })
).Render();

Defer renders a loading spinner immediately, then replaces it with the result once the async call returns. It composes naturally with all layout primitives.

Curiosity components