Function
Static Public Summary | ||
public |
box(val: *): * |
|
public |
checkContextType(T: Type): HOC assert context type |
|
public |
creates a choke that throttle fuction calls |
|
public |
combiner scope factory represents map of (sub)scopes. |
|
public |
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 scope factory represents value of fragment identifier. |
|
public |
get(state: *, pointer: *, notFound: *): * |
|
public |
handler(context: *, pairs: *): * |
|
public |
log component lifecycle |
|
public |
mapAttributes(node: *, f: *, deep: boolean): * |
|
public |
memoize component |
|
public |
transform ctx of component |
|
public |
add name to component - for debug messages |
|
public |
normalize(comp: *): * |
|
public |
specDecorator(options: *): * |
|
public |
add css styles as Object |
|
public |
unbox(state: *): * |
|
public |
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:
Name | Type | Attribute | Description |
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:
Name | Type | Attribute | Description |
T | Type | type to check context again (tcomb type) |
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:
Name | Type | Attribute | Description |
delta | Number | the delta between calls [ms] |
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.
public component(decoration: ...HOC): HOC source
import component from 'vulp/src/decorators/component.js'
apply multiple decorators on component
component(
someDeoraotor(),
someOther()
)(model => { ... })
Params:
Name | Type | Attribute | Description |
decoration | ...HOC | list of component decorators (hocs) |
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.
public curry(f: *, arity: *): * source
import curry from 'vulp/src/utils/curry.js'
Params:
Name | Type | Attribute | Description |
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:
Name | Type | Attribute | Description |
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' }
}
];
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:
Name | Type | Attribute | Description |
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 }
public get(state: *, pointer: *, notFound: *): * source
import {get} from 'vulp/src/state/index.js'
Params:
Name | Type | Attribute | Description |
state | * | ||
pointer | * | ||
notFound | * |
|
Return:
* |
public handler(context: *, pairs: *): * source
import handler from 'vulp/src/utils/patch.js'
Params:
Name | Type | Attribute | Description |
context | * | ||
pairs | * |
Return:
* |
public log(targets: *): HOC source
import log from 'vulp/src/decorators/log.js'
log component lifecycle
Params:
Name | Type | Attribute | Description |
targets | * |
|
public mapAttributes(node: *, f: *, deep: boolean): * source
import {mapAttributes} from 'vulp/src/decorators/utils.js'
Params:
Name | Type | Attribute | Description |
node | * | ||
f | * | ||
deep | boolean |
|
Return:
* |
public memoize(shouldUpdate: function(nextModel: Model, prevModel: Model): boolean): HOC source
import memoize from 'vulp/src/decorators/memoize.js'
memoize component
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)
public name(name: string): HOC source
import name from 'vulp/src/decorators/name.js'
add name to component - for debug messages
Params:
Name | Type | Attribute | Description |
name | string | component name |
public normalize(comp: *): * source
import {normalize} from 'vulp/src/decorators/utils.js'
Params:
Name | Type | Attribute | Description |
comp | * |
Return:
* |
public specDecorator(options: *): * source
import {specDecorator} from 'vulp/src/decorators/utils.js'
Params:
Name | Type | Attribute | Description |
options | * |
Return:
* |
public styler(): HOC source
import styler from 'vulp/src/decorators/styler.js'
add css styles as Object
styler()(() => (<div style={{ color: 'green'}}>))
public unbox(state: *): * source
import {unbox} from 'vulp/src/state/index.js'
Params:
Name | Type | Attribute | Description |
state | * |
Return:
* |