mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-25 12:52:27 +03:00
Remove obsolete values from Session API experiments.
This commit is contained in:
parent
1e2f4981ed
commit
12c0013ea3
@ -3,7 +3,6 @@ module MySession exposing (..)
|
|||||||
import Codec
|
import Codec
|
||||||
import DataSource exposing (DataSource)
|
import DataSource exposing (DataSource)
|
||||||
import DataSource.Env as Env
|
import DataSource.Env as Env
|
||||||
import Dict
|
|
||||||
import Server.Request exposing (Request)
|
import Server.Request exposing (Request)
|
||||||
import Server.Response as Response exposing (Response)
|
import Server.Response as Response exposing (Response)
|
||||||
import Server.Session as Session
|
import Server.Session as Session
|
||||||
@ -83,37 +82,3 @@ schema =
|
|||||||
type alias User =
|
type alias User =
|
||||||
{ id : Int
|
{ id : Int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
schemaUpdate getter value =
|
|
||||||
let
|
|
||||||
( name, codec ) =
|
|
||||||
schema |> getter
|
|
||||||
in
|
|
||||||
Session.oneUpdate name ((codec |> Codec.encodeToString 1) value)
|
|
||||||
|
|
||||||
|
|
||||||
schemaGet getter sessionDict =
|
|
||||||
let
|
|
||||||
( name, codec ) =
|
|
||||||
schema |> getter
|
|
||||||
in
|
|
||||||
sessionDict
|
|
||||||
|> Dict.get name
|
|
||||||
|> Maybe.map (codec |> Codec.decodeString)
|
|
||||||
|
|
||||||
|
|
||||||
exampleSchemaUpdate =
|
|
||||||
schemaUpdate .name "John Doe"
|
|
||||||
|
|
||||||
|
|
||||||
exampleSchemaGet =
|
|
||||||
schemaGet .name
|
|
||||||
|
|
||||||
|
|
||||||
exampleUpdate =
|
|
||||||
Session.oneUpdate "name" "NAME"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--|> Session.withFlash "message" ("Welcome " ++ name ++ "!")
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
module Server.Session exposing (Decoder, NotLoadedReason(..), Session(..), SessionUpdate(..), Value(..), clearFlashCookies, empty, expectSession, flash, flashPrefix, get, insert, noUpdates, oneUpdate, remove, setValues, succeed, unwrap, update, updateAllFields, withFlash, withFlash2, withSession)
|
module Server.Session exposing (Decoder, NotLoadedReason(..), Session(..), Value(..), clearFlashCookies, empty, expectSession, flashPrefix, get, insert, remove, setValues, succeed, unwrap, update, withFlash2, withSession)
|
||||||
|
|
||||||
{-|
|
{-|
|
||||||
|
|
||||||
@ -35,35 +35,6 @@ type Value
|
|||||||
| NewFlash String
|
| NewFlash String
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
|
||||||
type SessionUpdate
|
|
||||||
= SessionUpdate (Dict String String)
|
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
|
||||||
noUpdates : SessionUpdate
|
|
||||||
noUpdates =
|
|
||||||
SessionUpdate Dict.empty
|
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
|
||||||
oneUpdate : String -> String -> SessionUpdate
|
|
||||||
oneUpdate string value =
|
|
||||||
SessionUpdate (Dict.singleton string value)
|
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
|
||||||
updateAllFields : Dict String String -> SessionUpdate
|
|
||||||
updateAllFields updates =
|
|
||||||
SessionUpdate updates
|
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
|
||||||
withFlash : String -> String -> SessionUpdate -> SessionUpdate
|
|
||||||
withFlash string value (SessionUpdate sessionUpdate) =
|
|
||||||
SessionUpdate (sessionUpdate |> Dict.insert (flashPrefix ++ string) value)
|
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
{-| -}
|
||||||
withFlash2 : String -> String -> Session -> Session
|
withFlash2 : String -> String -> Session -> Session
|
||||||
withFlash2 key value (Session session) =
|
withFlash2 key value (Session session) =
|
||||||
@ -140,12 +111,6 @@ empty =
|
|||||||
Session Dict.empty
|
Session Dict.empty
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
|
||||||
flash : String -> String -> SessionUpdate
|
|
||||||
flash string value =
|
|
||||||
SessionUpdate (Dict.singleton (flashPrefix ++ string) value)
|
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
{-| -}
|
||||||
type NotLoadedReason
|
type NotLoadedReason
|
||||||
= NoCookies
|
= NoCookies
|
||||||
|
Loading…
Reference in New Issue
Block a user