Structuresliemeobn.elementary 0.3.3Elementary
AsyncForEach
An element that lazily renders HTML for each element of an AsyncSequence
.
struct AsyncForEach<Source, Content> where Source : AsyncSequence, Content : HTML
The this element can only be rendered in an async context (ie: by calling render(into:chunkSize:)
or renderAsync
).
ul {
let users = try await db.users.findAll()
AsyncForEach(users) { user in
li { "\(user.name) \(user.favoriteProgrammingLanguage)" }
}
}
Citizens in Elementary
Conformances
protocol HTML<Tag>
A type that represents HTML content that can be rendered.
Type members
init(Source, contentBuilder: @escaping (Source.Element) -> Content
) Creates a new async HTML element that renders the specified content for each element of the sequence.
Show system interfaces (2)
Hide system interfaces
Type features
Show implementation details (2)
Hide implementation details
Instance features
func environment<T>(TaskLocal<T>, T
) -> _ModifiedTaskLocal<T, Self> Sets the value of a
TaskLocal
for the duration of rendering the content.func render(
) -> String Renders the HTML content into a single string.
func render(into: some HTMLStreamWriter, chunkSize: Int
) async throws Renders the HTML content into a stream writer.
func renderAsync(
) async throws -> String Renders the HTML content into a single string asynchronously.
func renderFormatted(
) -> String Renders the HTML content into a formatted string.