Skip to content

Commit

Permalink
[sc-39872] Add new renderConcat to Array functions
Browse files Browse the repository at this point in the history
  • Loading branch information
gera-cameron committed Jan 7, 2025
1 parent 026e789 commit 04c12bd
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/DOM/Erumu/Array.purs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ in the array Msg type and used for routing during processing.
module DOM.Erumu.Array
( Msg(..)
, render
, renderConcat
, renderLift
, update
, updateF
, updateArrayWith
, updateF
) where

import Prelude

import Data.Identity (Identity(..))
import Data.Array (updateAt, mapWithIndex, (!!))
import Data.Array (updateAt, mapWithIndex, (!!), concat)
import Data.Maybe (Maybe(..), fromMaybe)
import Data.Traversable (sequence)
import Data.Newtype (unwrap)
Expand Down Expand Up @@ -62,6 +63,16 @@ renderLift renderItem items =
where
renderIdx idx item = renderItem (Msg idx) idx item

renderConcat ::
forall msg model.
(model -> Array (HTML msg)) ->
Array model ->
Array (HTML (Msg msg))
renderConcat renderItem items =
concat $ mapWithIndex renderIdx items
where
renderIdx idx item = map (Msg idx) <$> (renderItem item)

update ::
forall m msg model.
Applicative m =>
Expand Down

0 comments on commit 04c12bd

Please sign in to comment.