pete-murphy/elm-css/1.0.0

Html.Styled.Lazy

NOTE: Html.Lazy goes up to lazy8 and lazy7WithNonce, but Html.Styled.Lazy can only go up to lazy7 and lazy6WithNonce because it uses one of the arguments to track styling info.

Since all Elm functions are pure we have a guarantee that the same input

will always result in the same output. This module gives us tools to be lazy about building Html that utilize this fact.

Rather than immediately applying functions to their arguments, the lazy functions just bundle the function and arguments up for later. When diffing the old and new virtual DOM, it checks to see if all the arguments are equal by reference. If so, it skips calling the function!

This is a really cheap test and often makes things a lot faster, but definitely benchmark to be sure!

lazy : (a -> Html msg) -> a -> Html msg

A performance optimization that delays the building of virtual DOM nodes.

Calling (view model) will definitely build some virtual DOM, perhaps a lot of it. Calling (lazy view model) delays the call until later. During diffing, we can check to see if model is referentially equal to the previous value used, and if so, we just stop. No need to build up the tree structure and diff it, we know if the input to view is the same, the output must be the same!

lazy2 : (a -> b -> Html msg) -> a -> b -> Html msg

Same as lazy but checks on two arguments.

lazy3 : (a -> b -> c -> Html msg) -> a -> b -> c -> Html msg

Same as lazy but checks on three arguments.

lazy4 : (a -> b -> c -> d -> Html msg) -> a -> b -> c -> d -> Html msg

Same as lazy but checks on four arguments.

lazy5 : (a -> b -> c -> d -> e -> Html msg) -> a -> b -> c -> d -> e -> Html msg

Same as lazy but checks on five arguments.

lazy6 : (a -> b -> c -> d -> e -> f -> Html msg) -> a -> b -> c -> d -> e -> f -> Html msg

Same as lazy but checks on six arguments.

lazy7 : (a -> b -> c -> d -> e -> f -> g -> Html msg) -> a -> b -> c -> d -> e -> f -> g -> Html msg

Same as lazy but checks on seven arguments.

lazyWithNonce : String -> (a -> Html msg) -> a -> Html msg

Same as lazy but adds a nonce to the style tag so that it is compliant with the Content Security Policy of your website.

If you don't need a nonce, you should use lazy.

lazy2WithNonce : String -> (a -> b -> Html msg) -> a -> b -> Html msg

Same as lazy2 but adds a nonce to the style tag.

lazy3WithNonce : String -> (a -> b -> c -> Html msg) -> a -> b -> c -> Html msg

Same as lazy3 but adds a nonce to the style tag.

lazy4WithNonce : String -> (a -> b -> c -> d -> Html msg) -> a -> b -> c -> d -> Html msg

Same as lazy4 but adds a nonce to the style tag.

lazy5WithNonce : String -> (a -> b -> c -> d -> e -> Html msg) -> a -> b -> c -> d -> e -> Html msg

Same as lazy5 but adds a nonce to the style tag.

String
-> (a -> b -> c -> d -> e -> f -> Html msg)
-> a
-> b
-> c
-> d
-> e
-> f
-> Html msg

Same as lazy6 but adds a nonce to the style tag.