hariroshan/elm-native/1.0.0

NOTE: the latest version is 1.0.1

Native.Event

Events listeners for Nativescript UI Elements

Events

on : String -> Decoder msg -> Attribute msg

Allows you to build your own events and decoders

onBlur : msg -> Attribute msg

Listen for blur

onBusyChange : msg -> Attribute msg

Listen for busyChange

( { day : Int
, month : Int
, year : Int
}
-> msg
)
-> Attribute msg

Listen for dateChange

onEventWith : String -> EventOptions -> Decoder msg -> Attribute msg

Method values are kept under {custom: {[methodName]: value}} We will improve this in future

For example:

Event.onEventWithMethodCalls "touch"
    { methodCalls = [ "getX", "getY" ]
    , setters = []
    , getters = []
    }
    (D.map2 Tuple.pair
        (D.at [ "custom", "getX" ] D.float)
        (D.at [ "custom", "getY" ] D.float)
        |> D.map Msg
    )
onFocus : msg -> Attribute msg

Listen for focus

onItemTap : (Int -> msg) -> Attribute msg

Listen for itemTap in listView

onLoaded : msg -> Attribute msg

Listen for loaded

onReturnPress : msg -> Attribute msg

Listen for returnPress

onSelectedIndexChange : (Int -> msg) -> Attribute msg

Listens for selectedIndexChange

onTap : msg -> Attribute msg

Listen for tap

onTextChange : (String -> msg) -> Attribute msg

Listens for textChange event

onUnloaded : msg -> Attribute msg

Listen for unloaded

onValueChange : (Float -> msg) -> Attribute msg

Listen for valueChange

Decoder

decodeAttribute : String -> Decoder a -> Decoder a

Allows you to decode attributes from nativescript object

Usage:

listViewWithSingleTemplate
    [ items listViewModel ]
    [ button
        [ bindAttributeWithExpression "item-id" "$value.id"
        , on "tap" (Event.decodeAttribute "itemId" D.string |> D.map ItemTap)
        ]
        []
    ]