Copyright | (C) 2016-2025 David M. Johnson |
---|---|
License | BSD3-style (see the file LICENSE) |
Maintainer | David M. Johnson <code@dmj.io> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Miso.Types
Description
Synopsis
- data Component (name :: Symbol) model action = Component {}
- data SomeComponent = Eq model => SomeComponent (Component name model action)
- type Dynamic = ""
- data View action
- = VNode NS MisoString [Attribute action] [View action]
- | VText MisoString
- | VTextRaw MisoString
- | VComp MisoString [Attribute action] SomeComponent
- newtype Key = Key MisoString
- data Attribute action
- = Property MisoString Value
- | Event (Sink action -> Object -> LogLevel -> Events -> JSM ())
- | Styles (Map MisoString MisoString)
- data NS
- data CSS
- data LogLevel
- type MountPoint = MisoString
- class ToView a where
- type ToViewAction a
- toView :: a -> View (ToViewAction a)
- class ToKey key where
- defaultComponent :: forall model action (name :: Symbol). model -> (action -> Effect model action) -> (model -> View action) -> Component name model action
- component_ :: forall (name :: Symbol) model action a. (Eq model, KnownSymbol name) => Component name model action -> [Attribute a] -> View a
- getMountPoint :: Maybe MisoString -> MisoString
Types
data Component (name :: Symbol) model action Source #
Application entry point
Constructors
Component | |
Fields
|
Instances
ToView (Component name model action) Source # | |||||
Defined in Miso.Types Associated Types
| |||||
type ToViewAction (Component name model action) Source # | |||||
Defined in Miso.Types |
data SomeComponent Source #
Existential wrapper used to allow the nesting of Component
in Component
Constructors
Eq model => SomeComponent (Component name model action) |
Type synonym for Dynamically constructed Component
sampleComponent :: Component Dynamic Model Action
Core type for constructing a virtual DOM in Haskell
Constructors
VNode NS MisoString [Attribute action] [View action] | |
VText MisoString | |
VTextRaw MisoString | |
VComp MisoString [Attribute action] SomeComponent |
Instances
Functor View Source # | |||||
HasRouter (View a :: Type) Source # | View | ||||
HasLink (View a :: Type) Source # | For constructing type-safe links | ||||
IsString (View a) Source # |
| ||||
Defined in Miso.Types Methods fromString :: String -> View a # | |||||
ToHtml (View a) Source # | Render a | ||||
Defined in Miso.Render Methods toHtml :: View a -> ByteString Source # | |||||
ToHtml [View a] Source # | Render a | ||||
Defined in Miso.Render Methods toHtml :: [View a] -> ByteString Source # | |||||
ToView (View action) Source # | |||||
Defined in Miso.Types Associated Types
| |||||
type RouteT (View a :: Type) x Source # | |||||
Defined in Miso.Router | |||||
type MkLink (View a :: Type) b Source # | |||||
Defined in Miso.Types | |||||
type ToViewAction (View action) Source # | |||||
Defined in Miso.Types |
A unique key for a dom node.
This key is only used to speed up diffing the children of a DOM node, the actual content is not important. The keys of the children of a given DOM node must be unique. Failure to satisfy this invariant gives undefined behavior at runtime.
Constructors
Key MisoString |
data Attribute action Source #
Attribute of a vnode in a View
.
The Sink
callback can be used to dispatch actions which are fed back to
the update
function. This is especially useful for event handlers
like the onclick
attribute. The second argument represents the
vnode the attribute is attached to.
Constructors
Property MisoString Value | |
Event (Sink action -> Object -> LogLevel -> Events -> JSM ()) | |
Styles (Map MisoString MisoString) |
Allow users to express CSS and append it to head before the first draw
Href "http://domain.com/style.css
Constructors
Href MisoString |
|
Style MisoString |
|
Optional Logging for debugging miso internals (useful to see if prerendering is successful)
Constructors
Off | No debug logging, the default value used in |
DebugHydrate | Will warn if the structure or properties of the DOM vs. Virtual DOM differ during prerendering. |
DebugEvents | Will warn if an event cannot be routed to the Haskell event handler that raised it. Also will warn if an event handler is being used, yet it's not being listened for by the event delegator mount point. |
DebugNotify | Will warn if a |
DebugAll | Logs on all of the above |
type MountPoint = MisoString Source #
mountPoint
for Component
, e.g "body"
Classes
Convenience class for using View
Associated Types
type ToViewAction a Source #
Methods
toView :: a -> View (ToViewAction a) Source #
Instances
ToView (View action) Source # | |||||
Defined in Miso.Types Associated Types
| |||||
ToView (Component name model action) Source # | |||||
Defined in Miso.Types Associated Types
|
class ToKey key where Source #
Convert custom key types to Key
.
Instances of this class do not have to guarantee uniqueness of the
generated keys, it is up to the user to do so. toKey
must be an
injective function.
Instances
ToKey JSString Source # | Convert |
ToKey Key Source # | Identity instance |
ToKey Text Source # | Convert |
ToKey String Source # | Convert |
ToKey Double Source # | Convert |
ToKey Float Source # | Convert |
ToKey Int Source # | Convert |
ToKey Word Source # | Convert |
Smart Constructors
defaultComponent :: forall model action (name :: Symbol). model -> (action -> Effect model action) -> (model -> View action) -> Component name model action Source #
Smart constructor for Component
with sane defaults.
Components
component_ :: forall (name :: Symbol) model action a. (Eq model, KnownSymbol name) => Component name model action -> [Attribute a] -> View a Source #
Used in the view
function to embed an Component
into another Component
Use this function if you'd like send messages to this Component
at name
via
notify
or to read the state of this Component
via sample
.
Utils
getMountPoint :: Maybe MisoString -> MisoString Source #
Convenience for extracting mount point