From 9a00e919c85ecd7b17db1677595fd4aea5f83780 Mon Sep 17 00:00:00 2001 From: Brian Hicks Date: Fri, 25 Feb 2022 15:16:01 -0600 Subject: [PATCH] make maze generation lazy --- src/Main.elm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Main.elm b/src/Main.elm index 69feb3f..ebef9a5 100644 --- a/src/Main.elm +++ b/src/Main.elm @@ -12,6 +12,7 @@ import Html.Events.Extra.Touch as Touch exposing (Touch) import Html.Styled as Html exposing (Html) import Html.Styled.Attributes as HAttrs exposing (css) import Html.Styled.Events as Events +import Html.Styled.Lazy as Lazy import Json.Decode as Decode import Maze exposing (Maze) import Random @@ -225,9 +226,7 @@ view model = Route.Maze info -> [ viewMazeControls , viewCanvas model - , baseMaze info - |> Maze.generate (Random.initialSeed info.seed) - |> viewMaze + , Lazy.lazy carveAndView info ] Route.NotFound -> @@ -238,6 +237,13 @@ view model = } +carveAndView : { width : Int, height : Int, shape : Route.MazeShape, seed : Int } -> Html msg +carveAndView params = + baseMaze params + |> Maze.generate (Random.initialSeed params.seed) + |> viewMaze + + viewNewFormControls : Model -> Html Msg viewNewFormControls model = controlsBar