# @objectel/snabbel

> objectel binding for snabbdom

Latest version **0.1.1** (published 2019-01-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @objectel/snabbel
pnpm add @objectel/snabbel
yarn add @objectel/snabbel
bun add @objectel/snabbel
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2019-01-21 |
| First published | 2019-01-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 9.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | ENvironmentSet |
| Maintainers | environmentse7 |
| Keywords | snabbdom, objectel, callbag, reactive programming |

## Links

- npm: https://www.npmjs.com/package/@objectel/snabbel
- Repository: https://github.com/objectel/objectel
- Homepage: https://github.com/objectel/objectel#readme
- Issues: https://github.com/objectel/objectel/issues
- npm.io page: https://npm.io/package/@objectel/snabbel

## Dependencies (3)

- [objectel](https://npm.io/package/objectel.md) ^0.3.1
- [snabbdom](https://npm.io/package/snabbdom.md) ^0.7.3
- [objectel-events](https://npm.io/package/objectel-events.md) ^1.0.0

## Recent versions

- 0.1.1 (latest) — 2019-01-21
- 0.1.0 — 2019-01-16

## README

# snabbel

snabbel is library that provides some components and functions to use [snabbdom](https://github.com/snabbdom/snabbdom) in [objectel](https://github.com/ENvironmentSet/objectel) well.

## API

### VDOM({ [modules], [container], [children] })

| Arguments | Description |
|-----------|-------------|
| modules | modules for `snabbdom.init`, check [snabbdom's document](https://github.com/snabbdom/snabbdom#modules-documentation) about this. default value is empty array. |
| container | Root of Virtual dom. default value is DOM Fragment. |
| children | elements which will be applied vdom's event stream. |

* returns an element

Examples

Simple Counter

```jsx harmony
import { VDOM } from 'snabbel';
import * as Ol from 'objectel';

import Counter from './Counter';
import IncreaseButton from './IncreaseButton';

const app = document.getElementById('app');
const globalEventBus = Ol.createEventBus();
const vdom = (
  <VDOM container={app}>
    <Counter />
    <IncreaseButton amount={100} />
  </VDOM>
);

globalEventBus.Emit$(vdom(globalEventBus.Listen$));
```

### patchVnode(vnode)

| Arguments | Description |
|-----------|-------------|
| vnode | virtual node what you'd want to patch to vdom |

* returns `PATCH_VNODE` type event which be accepted by `VDOM` element

```jsx harmony
import { VDOM, patchVnode } from 'snabbel';
import * as Ol from 'objectel';
import h from 'snabbdom/h';

const once = value => (start, sink) => {
  if ( start !== 0) return;

  sink(0, () => {});
  sink(1, value);
  sink(2);
};

const app = document.getElementById('app');
const globalEventBus = Ol.createEventBus();
const vdom = <VDOM container={app} />;

globalEventBus.Emit$(once(patchVnode(h('p', {}, 'text'))));
globalEventBus.Emit$(vdom(globalEventBus.Listen$));
```

## vdomUpdated()

| Arguments | Description |
|-----------|-------------|

* returns `VDOM_UPDATED` type event which means "vdom has been updated'

---
_Source: https://npm.io/package/@objectel/snabbel · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
