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 model action = Component {}
- data SomeComponent = Eq model => SomeComponent (Component model action)
- data View action
- = VNode NS MisoString [Attribute action] [View action]
- | VText MisoString
- | VTextRaw MisoString
- | VComp [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
- newtype VTree = VTree {}
- type MountPoint = MisoString
- type DOMRef = JSVal
- class ToView a where
- type ToViewAction a
- toView :: a -> View (ToViewAction a)
- class ToKey key where
- component :: model -> (action -> Effect model action) -> (model -> View action) -> Component model action
- component_ :: forall model action a. Eq model => [Attribute a] -> Component model action -> View a
- getMountPoint :: Maybe MisoString -> MisoString
- node :: NS -> MisoString -> [Attribute action] -> [View action] -> View action
- text :: MisoString -> View action
- textRaw :: MisoString -> View action
- rawHtml :: MisoString -> View action
Types
data Component model action Source #
Application entry point
Constructors
Component | |
Fields
|
Instances
ToView (Component model action) Source # | |||||
Defined in Miso.Types Associated Types
| |||||
type ToViewAction (Component 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 model action) |
Core type for constructing a virtual DOM in Haskell
Constructors
VNode NS MisoString [Attribute action] [View action] | |
VText MisoString | |
VTextRaw MisoString | |
VComp [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 |
|
Sheet StyleSheet |
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. |
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 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
component :: model -> (action -> Effect model action) -> (model -> View action) -> Component model action Source #
Smart constructor for Component
with sane defaults.
Components
component_ :: forall model action a. Eq model => [Attribute a] -> Component model action -> View a Source #
Used in the view
function to embed an Component
into another Component
Utils
getMountPoint :: Maybe MisoString -> MisoString Source #
Convenience for extracting mount point
Combinators
node :: NS -> MisoString -> [Attribute action] -> [View action] -> View action Source #
Create a new Miso.Types.VNode
.
node ns tag key attrs children
creates a new node with tag tag
and Key
key
in the namespace ns
. All attrs
are called when
the node is created and its children are initialized to children
.
text :: MisoString -> View action Source #
Create a new Text
with the given content.
textRaw :: MisoString -> View action Source #
TextRaw
creation. Don't use directly
rawHtml :: MisoString -> View action Source #