mirror of
https://github.com/nunntom/elm-ui-select.git
synced 2024-11-29 16:52:25 +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 Browser.Dom as Dom
|
||||||
import Process
|
import Process
|
||||||
@ -144,3 +144,26 @@ calculateScrollTop { optionTop, optionBottom, menuViewPortY, menuHeight } =
|
|||||||
|
|
||||||
else
|
else
|
||||||
menuViewPortY
|
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
|
, perform, performWithRequest
|
||||||
, simulate, simulateWithRequest
|
, simulate, simulateWithRequest
|
||||||
, SimulateInputConfig, simulateFillIn, simulateArrowDown, simulateArrowUp, simulateClickOption, simulateEnterKey
|
, SimulateInputConfig, simulateFillIn, simulateArrowDown, simulateArrowUp, simulateClickOption, simulateEnterKey
|
||||||
|
, map
|
||||||
)
|
)
|
||||||
|
|
||||||
{-| Update the Select by returning Effects instead of Cmds.
|
{-| 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
|
@docs SimulateInputConfig, simulateFillIn, simulateArrowDown, simulateArrowUp, simulateClickOption, simulateEnterKey
|
||||||
|
|
||||||
|
|
||||||
|
# Mapping
|
||||||
|
|
||||||
|
@docs map
|
||||||
|
|
||||||
-}
|
-}
|
||||||
|
|
||||||
import Html
|
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
|
-- INTERNAL
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user