UNPKG

@motorcycle/mostly-html

Version:
26 lines 992 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var stream_1 = require("@motorcycle/stream"); var HtmlDomSource_1 = require("./HtmlDomSource"); var mostly_html_1 = require("mostly-html"); /** * Renders mostly-dom VNodes into HTML for server-side rendering. * @name Html<A = Element, B = Event>(sinks: HtmlSinks): HtmlSources<A, B> * @example * import { run } from '@motorcycle/run' * import { Html, HtmlSources, HtmlSinks } from '@motorcycle/mostly-html' * import { UI } from './UI' * import { observe } from '@motorcycle/stream' * * const { sources: { html$ } } = run<HtmlSources, HtmlSinks>(UI, Html) * * observe((html: string) => { /* Do something with html *\/ }, html$) */ function Html(sinks) { var view$ = sinks.view$; var html$ = stream_1.hold(stream_1.map(mostly_html_1.toHtml, view$)); var dom = new HtmlDomSource_1.HtmlDomSource([]); return { dom: dom, html$: html$ }; } exports.Html = Html; //# sourceMappingURL=Html.js.map