Home Manual Reference Source Repository

Function

Static Public Summary
public

box(val: *): *

public

assert context type

public

choke(delta: Number): function(path: String, f: Function)

creates a choke that throttle fuction calls

public

combiner(scopeMap: Map<string, ScopeFactory'>, input: Stream): Scope

combiner scope factory represents map of (sub)scopes.

public

component(decoration: ...HOC): HOC

apply multiple decorators on component

public

controller(controller: Map<string, any>): HOC

controller decorator.

public

curry(f: *, arity: *): *

public

cycle(viewF: BoundViewFactory, scopeF: BoundScopeFactory): Stream

pipes a to b and b to a -> cycle a and b

public

dispatch change sets

public

dom(container: DOMElement, rawComponent: Component): BoundViewFactory

This function is used to create the render part of your app.

public

fragment(opts: Object, input: Scope): Scope

fragment scope factory represents value of fragment identifier.

public

get(state: *, pointer: *, notFound: *): *

public

handler(context: *, pairs: *): *

public

log(targets: *): HOC

log component lifecycle

public

mapAttributes(node: *, f: *, deep: boolean): *

public

memoize(shouldUpdate: function(nextModel: Model, prevModel: Model): boolean): HOC

memoize component

public

mount(targets: Map<string, string>): HOC

transform ctx of component

public

name(name: string): HOC

add name to component - for debug messages

public

normalize(comp: *): *

public

specDecorator(options: *): *

public

styler(): HOC

add css styles as Object

public

unbox(state: *): *

public

value(init: Object, input: stream): Scope

value scope factory Scope will update and emit value on every patch action.

Static Public

public box(val: *): * source

import {box} from 'vulp/src/state/index.js'

Params:

NameTypeAttributeDescription
val *

Return:

*

public checkContextType(T: Type): HOC source

import checkContextType from 'vulp/src/decorators/checkContextType.js'

assert context type

import t from 'tcomb'

checkContextType(t.struct({
    someProp: t.String
}))(model => { ... })

Params:

NameTypeAttributeDescription
T Type

type to check context again (tcomb type)

Return:

HOC

public choke(delta: Number): function(path: String, f: Function) source

import choke from 'vulp/src/utils/choke.js'

creates a choke that throttle fuction calls

The returned choke function will throttle calls with the same path argument for delta milliseconds.

Params:

NameTypeAttributeDescription
delta Number

the delta between calls [ms]

Return:

function(path: String, f: Function)

public combiner(scopeMap: Map<string, ScopeFactory'>, input: Stream): Scope source

import combiner from 'vulp/src/scopes/combiner.js'

combiner scope factory represents map of (sub)scopes.

Params:

NameTypeAttributeDescription
scopeMap Map<string, ScopeFactory'>

the routing map

input Stream

input stream

Return:

Scope

public component(decoration: ...HOC): HOC source

import component from 'vulp/src/decorators/component.js'

apply multiple decorators on component

component(
    someDeoraotor(),
    someOther()
)(model => { ... })

Params:

NameTypeAttributeDescription
decoration ...HOC

list of component decorators (hocs)

Return:

HOC

public controller(controller: Map<string, any>): HOC source

import controller from 'vulp/src/decorators/controller.js'

controller decorator.

controller({
    click: (model) => { ... }
})(({ dispatch }) => (
    <input type='button' onClick={event => dispatch('click', event)} />
    // or
    <input type='button' onClick='click' />
))

You can dispatch actions to handlers in your controller when you call model.dispatch with the property name as first argument and an optional event as second argument.

If the property is a function, then the function will be called with model as the only argument. The model object has an additional property 'event', which contains the second argument from dispatch. Otherwise the property will just be dispatched.

Params:

NameTypeAttributeDescription
controller Map<string, any>

action map

Return:

HOC

public curry(f: *, arity: *): * source

import curry from 'vulp/src/utils/curry.js'

Params:

NameTypeAttributeDescription
f *
arity *

Return:

*

public cycle(viewF: BoundViewFactory, scopeF: BoundScopeFactory): Stream source

import cycle from 'vulp/src/utils/cycle.js'

pipes a to b and b to a -> cycle a and b

Params:

NameTypeAttributeDescription
viewF BoundViewFactory

view factory

scopeF BoundScopeFactory

scope factory

Return:

Stream

empty stream, use to end

public dispatchChangeSets(): HOC source

import dispatchChangeSets from 'vulp/src/decorators/dispatchChangeSets.js'

dispatch change sets

Usage:

dispatchChangeSets()(function({ dispatch }) {
        // some code...
        dispatch(['/count', v => v + 1])
})

A change set is an array of strings on even positions and some values on odd positions. The strings acts as path selector on the context object and the next element as value for the previous path. If the value element is a function, this function will be called with the value in the given path as argument. If the path string ends with '-' the operator in the resulting patch will be 'add' (info).

Example:

const changeSet = [
    '/foo/bar' : 42,
    '/someNumber' : n => n + 3,
    '/someList/-' : {name: 'baz'}
];

The function will be called with n = model.context.get('/someNumber'). The resulting patch set with n = 4:

const patchSet = [
    {
        op: 'replace',
        path: '/foo/bar',
        value: 42
    },
    {
        op: 'replace',
        path: '/someNumber',
        value: 7
    },
    {
        op: 'add',
        path: '/someList/-',
        value: { name: 'baz' }
    }
];

Return:

HOC

public dom(container: DOMElement, rawComponent: Component): BoundViewFactory source

import dom from 'vulp/src/views/dom.js'

This function is used to create the render part of your app. If the view receives a context object, it will pass the context through your component. All actions dispatched inside component, will be emitted from the view.

Params:

NameTypeAttributeDescription
container DOMElement

container dom element

rawComponent Component

deku component

public fragment(opts: Object, input: Scope): Scope source

import fragment from 'vulp/src/scopes/fragment.js'

fragment scope factory represents value of fragment identifier. Json structure: { value: String }

Params:

NameTypeAttributeDescription
opts Object

not used

input Scope

input stream

Return:

Scope

public get(state: *, pointer: *, notFound: *): * source

import {get} from 'vulp/src/state/index.js'

Params:

NameTypeAttributeDescription
state *
pointer *
notFound *
  • optional
  • default: null

Return:

*

public handler(context: *, pairs: *): * source

import handler from 'vulp/src/utils/patch.js'

Params:

NameTypeAttributeDescription
context *
pairs *

Return:

*

public log(targets: *): HOC source

import log from 'vulp/src/decorators/log.js'

log component lifecycle

Params:

NameTypeAttributeDescription
targets *
  • optional
  • default: defaultTargets

Return:

HOC

public mapAttributes(node: *, f: *, deep: boolean): * source

import {mapAttributes} from 'vulp/src/decorators/utils.js'

Params:

NameTypeAttributeDescription
node *
f *
deep boolean
  • optional
  • default: false

Return:

*

public memoize(shouldUpdate: function(nextModel: Model, prevModel: Model): boolean): HOC source

import memoize from 'vulp/src/decorators/memoize.js'

memoize component

Params:

NameTypeAttributeDescription
shouldUpdate function(nextModel: Model, prevModel: Model): boolean

list of component decorators (hocs)

Return:

HOC

public mount(targets: Map<string, string>): HOC source

import mount from 'vulp/src/decorators/mount.js'

transform ctx of component

mount({
    foo: '/some/value'
    bar: '/here/is/another/val'
})(component)

Params:

NameTypeAttributeDescription
targets Map<string, string>

transform description

Return:

HOC

public name(name: string): HOC source

import name from 'vulp/src/decorators/name.js'

add name to component - for debug messages

Params:

NameTypeAttributeDescription
name string

component name

Return:

HOC

public normalize(comp: *): * source

import {normalize} from 'vulp/src/decorators/utils.js'

Params:

NameTypeAttributeDescription
comp *

Return:

*

public specDecorator(options: *): * source

import {specDecorator} from 'vulp/src/decorators/utils.js'

Params:

NameTypeAttributeDescription
options *

Return:

*

public styler(): HOC source

import styler from 'vulp/src/decorators/styler.js'

add css styles as Object

styler()(() => (<div style={{ color: 'green'}}>))

Return:

HOC

public unbox(state: *): * source

import {unbox} from 'vulp/src/state/index.js'

Params:

NameTypeAttributeDescription
state *

Return:

*

public value(init: Object, input: stream): Scope source

import value from 'vulp/src/scopes/value.js'

value scope factory Scope will update and emit value on every patch action.

Params:

NameTypeAttributeDescription
init Object

init value as plain object

input stream

input flyd stream

Return:

Scope