Module

Turbine

Package
purescript-turbine
Repository
funkia/purescript-turbine

#Component Source

data Component :: Type -> Type -> Type

Instances

#runComponent Source

runComponent :: forall a o. String -> Component o a -> Effect Unit

#modelView Source

modelView :: forall x a p o. (o -> x -> Now p) -> (p -> x -> Component o a) -> (x -> Component (Record ()) p)

#merge Source

merge :: forall q p b o a. Union o p q => Component (Record o) a -> Component (Record p) b -> Component (Record q) (Record ())

Combines two components and merges their explicit output.

#(</>) Source

Operator alias for Turbine.merge (left-associative / precedence 0)

#dynamic Source

dynamic :: forall a o. Behavior (Component o a) -> Component (Record ()) (Behavior o)

Turns a behavior of a component into a component of a behavior. This function is used to create dynamic HTML where the structure of the HTML should change over time.

dynamic (map (\b -> if b else (div {} ) then) behavior)

#output Source

output :: forall q p o a. Union o p q => Component (Record o) a -> (a -> Record p) -> Component (Record q) a

Copies non-explicit output into explicit output.

This function is often used in infix form as in the following example.

button (text "Fire missiles!") `output` (\o -> { fireMissiles })

#Key Source

class Key a  where

Type class implemented by Int, Number, and String. Used to represent overloads.

Members

Instances

#list Source

list :: forall k p o a. Key k => (a -> Component o p) -> Behavior (Array a) -> (a -> k) -> Component (Record ()) (Behavior (Array o))

#MapRecord Source

class MapRecord (xs :: RowList) (row :: Row Type) f (from :: Row Type) (to :: Row Type) | xs -> row f from to where

Members

Instances

#static Source

static :: forall row c a. RowToList row c => MapRecord c row Behavior () a => Record row -> Record a

A helper function used to convert static values in records into constant behaviors.

Component functions often takes a large amount of behaviors as input. But, sometimes all that is required is static values, that is, constant behaviors. In these cases it can sometimes be tedious to write records like the following:

{ foo: pure 1, bar: pure 2, baz: pure 3, more: pure 4, fields: pure 5 }

The static function applies pure to each value in the given record. As such, the above can be shortened into the following.

static { foo: 1, bar: 2, baz: 3, more: 4, fields: 5 }

#withStatic Source

withStatic :: forall xs p' q' q p o. RowToList p xs => MapRecord xs p Behavior () p' => Union o p' q' => Nub q' q => Record o -> Record p -> Record q

A function closely related to static. Usefull in cases where a component function is to be supplied with both a set of static values (constant behaviors). The function applies static to its seconds argument and merges the two records.

It is often used in infix form as in the following example.

{ foo: behA, bar: behB } `withStatic` { baz: 3, more: 4, fields: 5 }