#VNodeProxy Source

newtype VNodeProxy


#VNodeData Source

type VNodeData = { attrs :: Map String String, hook :: VNodeHookObjectProxy, on :: VNodeEventObject }

Attrs allows you to set attributes on DOM elements.

The event listeners module gives powerful capabilities for attaching event listeners. You can attach a function to an event on a vnode by supplying an object at on with a property corresponding to the name of the event you want to listen to. The function will be called when the event happens and will be passed the event object that belongs to it.

Hooks are a way to hook into the lifecycle of DOM nodes. Snabbdom offers a rich selection of hooks. Hooks are used both by modules to extend Snabbdom, and in normal code for executing arbitrary code at desired points in the life of a virtual node.

#VNodeEventObject Source

#toVNodeEventObject Source

toVNodeEventObject :: forall a. Map String (a -> Effect Unit) -> VNodeEventObject

Transform a Map String representing a VNodeEventObject into its native counter part

#VNodeHookObject Source

type VNodeHookObject = { destroy :: Maybe (VNodeProxy -> Effect Unit), insert :: Maybe (VNodeProxy -> Effect Unit), update :: Maybe (VNodeProxy -> VNodeProxy -> Effect Unit) }

The insert hook is invoked once the DOM element for a vnode has been inserted into the document and the rest of the patch cycle is done. This means that you can do DOM measurements (like using getBoundingClientRect in this hook safely, knowing that no elements will be changed afterwards that could affect the position of the inserted elements.

The destroy hook is invoked on a virtual node when its DOM element is removed from the DOM or if its parent is being removed from the DOM.

The update hook is invoked whenever an element is being updated

#getElementImpl Source

getElementImpl :: forall a. VNodeProxy -> (a -> Maybe a) -> Maybe a -> Maybe Element

#getElement Source

getElement :: VNodeProxy -> Maybe Element

Safely get the elm from a VNode

#VNodeHookObjectProxy Source

#toVNodeHookObjectProxy Source

toVNodeHookObjectProxy :: VNodeHookObject -> VNodeHookObjectProxy

Transform a VNodeHookObject into its native counter part

#VDOM Source

data VDOM :: Type -> Type

#patch Source

patch :: VNodeProxy -> VNodeProxy -> Effect Unit

The patch function returned by init takes two arguments. The first is a DOM element or a vnode representing the current view. The second is a vnode representing the new, updated view. If a DOM element with a parent is passed, newVnode will be turned into a DOM node, and the passed element will be replaced by the created DOM node. If an old vnode is passed, Snabbdom will efficiently modify it to match the description in the new vnode. Any old vnode passed must be the resulting vnode from a previous call to patch. This is necessary since Snabbdom stores information in the vnode. This makes it possible to implement a simpler and more performant architecture. This also avoids the creation of a new old vnode tree.

#patchInitial Source

patchInitial :: Element -> VNodeProxy -> Effect Unit

Same as patch, but patches an initial DOM Element instead.

#patchInitialSelector Source

patchInitialSelector :: String -> VNodeProxy -> Effect Unit

Same as patch initial, but takes a selector instead of a DOM Element.

#text Source

text :: String -> VNodeProxy

Turns a String into a VNode

#h Source

h :: String -> VNodeData -> Array VNodeProxy -> VNodeProxy

It is recommended that you use snabbdom/h to create vnodes. h accepts a tag/selector as a string, an optional data object and an optional string or array of children.

#updateValueHook Source

updateValueHook :: VNodeProxy -> VNodeProxy -> Effect Unit

A hook that updates the value whenever it's attribute gets updated.