From 077809768a84b928172440d6503795493f37aca5 Mon Sep 17 00:00:00 2001 From: Dillon Kearns Date: Mon, 24 Jan 2022 19:38:53 -0800 Subject: [PATCH] Extract eagerLoad helper in ContentCache. --- src/Pages/ContentCache.elm | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/Pages/ContentCache.elm b/src/Pages/ContentCache.elm index a1f008f7..70daab6c 100644 --- a/src/Pages/ContentCache.elm +++ b/src/Pages/ContentCache.elm @@ -4,6 +4,7 @@ module Pages.ContentCache exposing , Entry(..) , Path , contentJsonDecoder + , eagerLoad , init , is404 , lazyLoad @@ -81,18 +82,27 @@ lazyLoad urls cache = ) Nothing -> - urls.currentUrl - |> httpTask - |> Task.map - (\downloadedContent -> - ( urls.currentUrl - , downloadedContent - , update - cache - urls - downloadedContent - ) - ) + eagerLoad urls cache + + +{-| -} +eagerLoad : + { currentUrl : Url, basePath : List String } + -> ContentCache + -> Task Http.Error ( Url, ContentJson, ContentCache ) +eagerLoad urls cache = + urls.currentUrl + |> httpTask + |> Task.map + (\downloadedContent -> + ( urls.currentUrl + , downloadedContent + , update + cache + urls + downloadedContent + ) + ) httpTask : Url -> Task Http.Error ContentJson