hyperbole-0.4.2: Interactive HTML apps using type-safe serverside Haskell
Safe HaskellNone
LanguageGHC2021

Web.Hyperbole.View.Event

Synopsis

Documentation

onLoad :: ViewAction (Action id) => Action id -> DelayMs -> Mod id Source #

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

viewUpdating :: Int -> View Progress ()
viewUpdating prg = do
  let pct = fromIntegral prg / 100
  Progress taskId _ <- viewId
  col (onLoad (CheckProgress prg) 0) $ do
    progressBar pct $ do
      el grow $ text $ "Task" <> pack (show taskId)

onClick :: ViewAction (Action id) => Action id -> Mod id Source #

onInput :: ViewAction (Action id) => (Text -> Action id) -> DelayMs -> Mod id 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

onKeyDown :: ViewAction (Action id) => Key -> Action id -> Mod id Source #

onKeyUp :: ViewAction (Action id) => Key -> Action id -> Mod id Source #

data Key Source #

Instances

Instances details
Read Key Source # 
Instance details

Defined in Web.Hyperbole.View.Event

Show Key Source # 
Instance details

Defined in Web.Hyperbole.View.Event

Methods

showsPrec :: Int -> Key -> ShowS #

show :: Key -> String #

showList :: [Key] -> ShowS #

toActionInput :: ViewAction a => (Text -> a) -> Text Source #

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

onRequest :: Mod id -> Mod id Source #

Apply a Mod only when a request is in flight. See Example.Page.Contact

contactEditView :: User -> View Contact ()
contactEditView u = do
  el (hide . onRequest flexCol) contactLoading
  el (onRequest hide) $ contactEdit View Save u

dataTarget :: ViewId a => a -> Mod x Source #

Internal

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

Allow inputs to trigger actions for a different view