@@ -43,6 +43,7 @@ module Flare
43
43
, liftSF
44
44
, foldp
45
45
, setupFlare
46
+ , flareWith
46
47
, runFlareWith
47
48
, runFlare
48
49
, runFlareShow
@@ -385,18 +386,27 @@ setupFlare (UI setupUI) = do
385
386
(Flare components signal) <- setupUI
386
387
pure { components, signal }
387
388
389
+ -- | Renders a Flare UI to the DOM and sets up all event handlers. The ID
390
+ -- | specifies the HTML element to which the controls are attached. The
391
+ -- | handler function argument handles the `Signal` inside the `Flare`.
392
+ flareWith :: forall e a . ElementId
393
+ -> (S.Signal a -> Eff (dom :: DOM , channel :: CHANNEL | e ) Unit )
394
+ -> UI e a
395
+ -> Eff (dom :: DOM , channel :: CHANNEL | e ) Unit
396
+ flareWith controls handler (UI setupUI) = do
397
+ (Flare components signal) <- setupUI
398
+ removeChildren controls
399
+ traverse_ (appendComponent controls) components
400
+ handler signal
401
+
388
402
-- | Renders a Flare UI to the DOM and sets up all event handlers. The ID
389
403
-- | specifies the HTML element to which the controls are attached. The
390
404
-- | function argument will be mapped over the `Signal` inside the `Flare`.
391
405
runFlareWith :: forall e a . ElementId
392
406
-> (a -> Eff (dom :: DOM , channel :: CHANNEL | e ) Unit )
393
407
-> UI e a
394
408
-> Eff (dom :: DOM , channel :: CHANNEL | e ) Unit
395
- runFlareWith controls handler (UI setupUI) = do
396
- (Flare components signal) <- setupUI
397
- removeChildren controls
398
- traverse_ (appendComponent controls) components
399
- S .runSignal (map handler signal)
409
+ runFlareWith controls handler ui = flareWith controls (S .runSignal <<< map handler) ui
400
410
401
411
-- | Renders a Flare UI to the DOM and sets up all event handlers. The two IDs
402
412
-- | specify the DOM elements to which the controls and the output will be
0 commit comments