From 5293eb40032cdd361cf98de5e631070c8ad64ff8 Mon Sep 17 00:00:00 2001 From: Bram Date: Mon, 18 Dec 2023 01:30:15 +0100 Subject: [PATCH] Add Envelope function to extract settings values --- src/Internal/Values/Envelope.elm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Internal/Values/Envelope.elm b/src/Internal/Values/Envelope.elm index ba60a6b..4f9a13b 100644 --- a/src/Internal/Values/Envelope.elm +++ b/src/Internal/Values/Envelope.elm @@ -1,7 +1,7 @@ module Internal.Values.Envelope exposing ( Envelope, init , map, mapMaybe - , Settings, mapSettings + , Settings, mapSettings, extractSettings , getContent, extract , encode, decoder ) @@ -22,7 +22,7 @@ settings that can be adjusted manually. ## Settings -@docs Settings, mapSettings +@docs Settings, mapSettings, extractSettings ## Extract @@ -149,6 +149,16 @@ extract f (Envelope data) = f data.content +{-| Map a function on the settings, effectively getting data that way. + +This can be helpful if you have a UI that displays custom settings to a user. + +-} +extractSettings : (Settings -> b) -> Envelope a -> b +extractSettings f (Envelope data) = + f data.settings + + {-| Get the original item that is stored inside an Envelope. Make sure that you're only using this if you're interested in the actual value!