Module

React.Basic.DOM.Components.GlobalEvents

Package
purescript-react-basic
Repository
lumihq/purescript-react-basic

These helper components register and unregister event callbacks using React's the lifecycle callbacks. They're useful for declaratively defining global behavior which is associated with a particular component being mounted without having to wire all that lifecycle logic up manually.

For example:

render self =
  R.div
    { className: "dropdown-wrapper"
    , children:
        [ dropdownButton
        , guard showDropdown $
            windowEvent
              { eventType: EventType "click"
              , options: defaultOptions
              , handler: \_ -> send self CloseDropdown
              }
              dropdownMenu
        ]
    }

#EventHandlerOptions Source

type EventHandlerOptions = { capture :: Boolean, once :: Boolean, passive :: Boolean }

#globalEvent Source

globalEvent :: EventTarget -> { eventType :: EventType, handler :: Event -> Effect Unit, options :: EventHandlerOptions } -> JSX -> JSX

#globalEvents Source

globalEvents :: EventTarget -> Array { eventType :: EventType, handler :: Event -> Effect Unit, options :: EventHandlerOptions } -> JSX -> JSX

#windowEvent Source

windowEvent :: { eventType :: EventType, handler :: Event -> Effect Unit, options :: EventHandlerOptions } -> JSX -> JSX

#windowEvents Source

windowEvents :: Array { eventType :: EventType, handler :: Event -> Effect Unit, options :: EventHandlerOptions } -> JSX -> JSX