From cbdd99d9493362a19b140ecf0f82579bfb8e2115 Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Mon, 19 Aug 2019 20:35:30 +0200 Subject: [PATCH] Make loop handle Component inside Now --- src/component.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/component.ts b/src/component.ts index 5e308ab..c2614d4 100644 --- a/src/component.ts +++ b/src/component.ts @@ -255,7 +255,7 @@ const placeholderProxyHandler = { class LoopComponent extends Component { constructor( - private f: (o: O) => Child, + private f: (o: O) => Child | Now>, private placeholderNames?: string[] ) { super(); @@ -271,10 +271,9 @@ class LoopComponent extends Component { } } } - const { output } = toComponent(this.f(placeholderObject)).run( - parent, - destroyed - ); + const res = this.f(placeholderObject); + const child = Now.is(res) ? runNow(res) : res; + const { output } = toComponent(child).run(parent, destroyed); const needed = Object.keys(placeholderObject); for (const name of needed) { if (name === "destroyed") { @@ -290,7 +289,7 @@ class LoopComponent extends Component { } export function loop( - f: (o: O) => Component, + f: (o: O) => Child | Now>, placeholderNames?: string[] ): Component { const f2 = isGeneratorFunction(f) ? fgo(f) : f;