mirror of
https://github.com/nunntom/elm-ui-select.git
synced 2024-11-26 13:27:26 +03:00
Add Effect.map
This commit is contained in:
parent
03838bd980
commit
acba4ea11e
@ -1,4 +1,4 @@
|
||||
module Internal.Effect exposing (Effect(..), batch, none, perform, simulate)
|
||||
module Internal.Effect exposing (Effect(..), batch, map, none, perform, simulate)
|
||||
|
||||
import Browser.Dom as Dom
|
||||
import Process
|
||||
@ -144,3 +144,26 @@ calculateScrollTop { optionTop, optionBottom, menuViewPortY, menuHeight } =
|
||||
|
||||
else
|
||||
menuViewPortY
|
||||
|
||||
|
||||
map : (msg -> msg2) -> Effect effect msg -> Effect effect msg2
|
||||
map toMsg effect =
|
||||
case effect of
|
||||
GetContainerAndMenuElements msg ids ->
|
||||
GetContainerAndMenuElements (msg >> toMsg) ids
|
||||
|
||||
GetElementsAndScrollMenu msg ids ->
|
||||
GetElementsAndScrollMenu (toMsg msg) ids
|
||||
|
||||
Batch effects ->
|
||||
List.map (map toMsg) effects
|
||||
|> Batch
|
||||
|
||||
Request eff ->
|
||||
Request eff
|
||||
|
||||
Debounce msg delay val ->
|
||||
Debounce (msg >> toMsg) delay val
|
||||
|
||||
None ->
|
||||
None
|
||||
|
@ -4,6 +4,7 @@ module Select.Effect exposing
|
||||
, perform, performWithRequest
|
||||
, simulate, simulateWithRequest
|
||||
, SimulateInputConfig, simulateFillIn, simulateArrowDown, simulateArrowUp, simulateClickOption, simulateEnterKey
|
||||
, map
|
||||
)
|
||||
|
||||
{-| Update the Select by returning Effects instead of Cmds.
|
||||
@ -36,6 +37,11 @@ you don't need this module.
|
||||
|
||||
@docs SimulateInputConfig, simulateFillIn, simulateArrowDown, simulateArrowUp, simulateClickOption, simulateEnterKey
|
||||
|
||||
|
||||
# Mapping
|
||||
|
||||
@docs map
|
||||
|
||||
-}
|
||||
|
||||
import Html
|
||||
@ -339,6 +345,17 @@ simulateClickOption config model optionLabel =
|
||||
|
||||
|
||||
|
||||
-- MAP
|
||||
|
||||
|
||||
{-| Map Effect from one msg type to another
|
||||
-}
|
||||
map : (msg -> msg2) -> Effect effect msg -> Effect effect msg2
|
||||
map =
|
||||
Effect.map
|
||||
|
||||
|
||||
|
||||
-- INTERNAL
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user