Module

Turbine

Package
purescript-turbine
Repository
funkia/purescript-turbine

#Component Source

#runComponent Source

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

#modelView Source

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

#merge Source

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

Combines two components and merges their selected output.

#(</>) Source

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

#dynamic Source

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

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)

#use Source

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

Copies non-selected output into selected output.

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

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

#component Source

component :: forall p o a. (o -> Now (ComponentResult a o p)) -> Component p (Record ())

#ComponentResult Source

type ComponentResult a o p = { available :: p, component :: Component a o }

#output Source

output :: forall f p o a. Applicative f => Component a o -> p -> f (ComponentResult a o p)

#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 o b a. Key k => (a -> Component b o) -> Behavior (Array a) -> (a -> k) -> Component (Behavior (Array o)) (Record ())

#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 }