Skip to content

Commit

Permalink
Add keyedLazy to Svg as well
Browse files Browse the repository at this point in the history
  • Loading branch information
micahhahn committed Sep 2, 2022
1 parent 6fe7769 commit 86bd904
Showing 1 changed file with 63 additions and 1 deletion.
64 changes: 63 additions & 1 deletion src/Svg/Styled/Lazy.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
module Svg.Styled.Lazy exposing (lazy, lazy2, lazy3, lazy4, lazy5, lazy6, lazy7)
module Svg.Styled.Lazy exposing
( lazy, lazy2, lazy3, lazy4, lazy5, lazy6, lazy7
, keyedLazy, keyedLazy2, keyedLazy3, keyedLazy4, keyedLazy5, keyedLazy6, keyedLazy7
)

{-| **NOTE:** `Svg.Lazy` goes up to `lazy8`, but `Svg.Styled.Lazy` can only go
up to `lazy7` because it uses one of the arguments to track styling info.
Expand All @@ -16,6 +19,7 @@ This is a really cheap test and often makes things a lot faster, but definitely
benchmark to be sure!
@docs lazy, lazy2, lazy3, lazy4, lazy5, lazy6, lazy7
@docs keyedLazy, keyedLazy2, keyedLazy3, keyedLazy4, keyedLazy5, keyedLazy6, keyedLazy7
-}

Expand Down Expand Up @@ -77,3 +81,61 @@ lazy6 =
lazy7 : (a -> b -> c -> d -> e -> f -> g -> Svg msg) -> a -> b -> c -> d -> e -> f -> g -> Svg msg
lazy7 =
VirtualDom.Styled.lazy7


{-| Much like `lazy`, but allows specifying a key for the created `Svg` node. This can increase performance in cases when you want to lazily generate a list of nodes.
This key becomes the id of the root node and all css that is generated will be scoped to that id. This allows the browser to spend less time calculating styles as there won't be lots styles with the same class name.
Some notes about using this function:
- The key must be a valid HTML id
- The key should be unique among other ids on the page and unique among the keys for other siblings
- No other id attribute should be specified on the root node - it will be ignored
-}
keyedLazy : (a -> ( String, Svg msg )) -> a -> Svg msg
keyedLazy =
VirtualDom.Styled.keyedLazy


{-| Same as `keyedLazy` but checks on two arguments.
-}
keyedLazy2 : (a -> b -> ( String, Svg msg )) -> a -> b -> Svg msg
keyedLazy2 =
VirtualDom.Styled.keyedLazy2


{-| Same as `keyedLazy` but checks on three arguments.
-}
keyedLazy3 : (a -> b -> c -> ( String, Svg msg )) -> a -> b -> c -> Svg msg
keyedLazy3 =
VirtualDom.Styled.keyedLazy3


{-| Same as `keyedLazy` but checks on four arguments.
-}
keyedLazy4 : (a -> b -> c -> d -> ( String, Svg msg )) -> a -> b -> c -> d -> Svg msg
keyedLazy4 =
VirtualDom.Styled.keyedLazy4


{-| Same as `keyedLazy` but checks on five arguments.
-}
keyedLazy5 : (a -> b -> c -> d -> e -> ( String, Svg msg )) -> a -> b -> c -> d -> e -> Svg msg
keyedLazy5 =
VirtualDom.Styled.keyedLazy5


{-| Same as `keyedLazy` but checks on six arguments.
-}
keyedLazy6 : (a -> b -> c -> d -> e -> f -> ( String, Svg msg )) -> a -> b -> c -> d -> e -> f -> Svg msg
keyedLazy6 =
VirtualDom.Styled.keyedLazy6


{-| Same as `keyedLazy` but checks on seven arguments.
-}
keyedLazy7 : (a -> b -> c -> d -> e -> f -> g -> ( String, Svg msg )) -> a -> b -> c -> d -> e -> f -> g -> Svg msg
keyedLazy7 =
VirtualDom.Styled.keyedLazy7

0 comments on commit 86bd904

Please sign in to comment.