0.1.0 • Published 5 years ago

callbag-component v0.1.0

Weekly downloads
5
License
MIT
Repository
github
Last release
5 years ago

callbag-component

callbag-component is wrapper of Custom element 1.0 API.

Provides reactive custom element via callbag

API

Component

component(intent$, model$, view$)

ArgumentsDescription
intent$takes DOM element(connected component). returns source of intent
model$takes source of intent. returns source of model
view$takes source of model. returns source of DOM Node, which will replace custom element's children

Example:

import { component, fromIntent } from 'callbag-component';
import fromEvent from 'callbag-from-event';
import map from 'callbag-map';

const Counter = component(
  element => fromEvent(element, 'click'),
  fromIntent(prev => prev + 1, 0),
  map(count => document.createTextNode(`count: ${count}`)),
);

fromIntent(reducer, preloadedModel)

ArgumentsDescription
reducertakes lastly calculated model and lastly produced intent, returns new model
preloadedModelinitial model
import { component, fromIntent } from 'callbag-component';
import fromEvent from 'callbag-from-event';
import map from 'callbag-map';

const Counter = component(
  element => fromEvent(element, 'click'),
  fromIntent(prev => prev + 1, 0),
  map(count => document.createTextNode(`count: ${count}`)),
);
0.1.0

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago