Skip to content

Commit d685859

Browse files
authored
Merge pull request #1098 from kerams/yield
Add YieldFrom to CollectionBuilder
2 parents 8baf641 + 149ea69 commit d685859

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/Fabulous.Tests/APISketchTests/TestUI.Widgets.fs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,6 @@ module TestUI_Widgets =
167167
: Content<'msg> =
168168
CollectionBuilder.yieldImpl x
169169

170-
[<Extension>]
171-
static member inline YieldFrom<'msg, 'marker, 'itemMarker when 'msg: equality and 'itemMarker :> IMarker>
172-
(_: CollectionBuilder<'msg, 'marker, IMarker>, x: WidgetBuilder<'msg, 'itemMarker> seq)
173-
: Content<'msg> =
174-
// TODO optimize this one with addMut
175-
{ Widgets = x |> Seq.map(fun wb -> wb.Compile()) |> Seq.toArray |> MutStackArray1.fromArray }
176-
177-
178-
179-
180170
///------------------
181171
type StatefulView<'arg, 'model, 'msg, 'marker when 'msg: equality> =
182172
{ Init: 'arg -> 'model

src/Fabulous/Builders.fs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,14 @@ type CollectionBuilder<'msg, 'marker, 'itemMarker when 'msg: equality> =
240240

241241
res
242242

243+
member inline _.YieldFrom(sequence: WidgetBuilder<'msg, 'itemMarker> seq) : Content<'msg> =
244+
// TODO optimize this one with addMut
245+
{ Widgets =
246+
sequence
247+
|> Seq.map(fun wb -> wb.Compile())
248+
|> Seq.toArray
249+
|> MutStackArray1.fromArray }
250+
243251
[<EditorBrowsable(EditorBrowsableState.Never)>]
244252
member inline x.AddScalar(attr: ScalarAttribute) =
245253
let struct (scalarAttributes, widgetAttributes, widgetCollectionAttributes, environmentAttributes) =

0 commit comments

Comments
 (0)