hyperbole-0.5.0: Interactive HTML apps using type-safe serverside Haskell
Safe HaskellSafe-Inferred
LanguageGHC2021

Web.Hyperbole.HyperView.Event

Synopsis

Documentation

onLoad :: (ViewAction (Action id), ViewContext a ~ id, Attributable a) => Action id -> DelayMs -> Attributes a -> Attributes a Source #

Send the action after N milliseconds. Can be used to implement lazy loading or polling. See Example.Page.Concurrent

viewTaskLoad :: View LazyData ()
viewTaskLoad = do
  -- 100ms after rendering, get the details
  el @ onLoad Details 100 ~ bg GrayLight . textAlign AlignCenter $ do
    text "..."

onInput :: (ViewAction (Action id), ViewContext a ~ id, Attributable a) => (Text -> Action id) -> DelayMs -> Attributes a -> Attributes a Source #

Run an action when the user types into an input or textarea.

WARNING: a short delay can result in poor performance. It is not recommended to set the value of the input

input (onInput OnSearch) 250 id

onChange :: (ViewAction (Action id), ViewContext a ~ id, Attributable a) => (value -> Action id) -> Attributes a -> Attributes a Source #

data Key Source #

Instances

Instances details
Read Key Source # 
Instance details

Defined in Web.Hyperbole.HyperView.Event

Show Key Source # 
Instance details

Defined in Web.Hyperbole.HyperView.Event

Methods

showsPrec :: Int -> Key -> ShowS #

show :: Key -> String #

showList :: [Key] -> ShowS #

toActionInput :: ViewAction a => (val -> a) -> Encoded Source #

Serialize a constructor that expects a single input, like `data MyAction = GoSearch Text`

dataTarget :: (ViewId id, ViewContext a ~ id, Attributable a) => id -> Attributes a -> Attributes a Source #

Internal

target :: forall id ctx. (HyperViewHandled id ctx, ViewId id) => id -> View id () -> View ctx () Source #

Allow inputs to trigger actions for a different view

targetView :: View Controls ()
targetView = do
  target Message $ do
    button (SetMessage "Targeted!") ~ btn $ "Target SetMessage"