Skip to content

Commit

Permalink
renamed sink
Browse files Browse the repository at this point in the history
  • Loading branch information
sliemeobn committed Jun 19, 2024
1 parent 0a32fa1 commit 11b8b74
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Sources/Elementary/Core/Html+Rendering.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ public extension Html {
return renderer.collect()
}

consuming func render(into sink: @escaping (String) -> Void) {
var renderer = HtmlStreamRenderer(sink: sink)
consuming func render(into writer: @escaping (String) -> Void) {
var renderer = HtmlStreamRenderer(writer: writer)
Self._render(self, into: &renderer, with: .emptyContext)
}

Expand Down
5 changes: 3 additions & 2 deletions Sources/Elementary/Core/HtmlTextRenderer.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// NOTE: an async version of this could be interesteing, where the components content can by asnc, and the renderer is an async stream... probably a bit complex though
// TODO: clean this up a bit

struct HtmlTextRenderer: _HtmlRendering {
private var result: String = ""
Expand All @@ -10,10 +11,10 @@ struct HtmlTextRenderer: _HtmlRendering {
}

struct HtmlStreamRenderer: _HtmlRendering {
let sink: (String) -> Void
let writer: (String) -> Void

mutating func appendToken(_ token: consuming _HtmlRenderToken) {
sink(token.renderedValue)
writer(token.renderedValue)
}
}

Expand Down

0 comments on commit 11b8b74

Please sign in to comment.