1.0.0 • Published 7 years ago

@motorcycle/mostly-html v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

@motorcycle/mostly-html -- 0.0.0

Server-side rendering for Motorcycle.ts

Get it

yarn add @motorcycle/mostly-html
# or
npm install --save @motorcycle/mostly-html

API Documentation

All functions are curried!

export type HtmlSources<A = Element, B = Event> = {
  readonly html$: Stream<HtmlString>
  readonly dom: DomSource<A, B>
}

Html\<A = Element, B = Event>(sinks: HtmlSinks): HtmlSources\<A, B>

Renders mostly-dom VNodes into HTML for server-side rendering.

const { sources: { html$ } } = run<HtmlSources, HtmlSinks>(UI, Html)

observe((html: string) => { / Do something with html \/ }, html$)

</details>

<details>
  <summary>See the code</summary>

```typescript

export function Html<A = Element, B = Event>(sinks: HtmlSinks): HtmlSources<A, B> {
  const { view$ } = sinks

  const html$ = hold(map(toHtml, view$))
  const dom = new HtmlDomSource<A, B>([])

  return { dom, html$ }
}

HtmlSinks

export type HtmlSinks = {
  readonly view$: Stream<VNode>
}