cycle-snabbdom icon indicating copy to clipboard operation
cycle-snabbdom copied to clipboard

Access snabbdom-to-html modules when using makeHTMLDriver

Open TylorS opened this issue 9 years ago • 1 comments

Overview

Add modules option for makeHTMLDriver

import Rx from 'rx'
-import toHTML from 'snabbdom-to-html'
+import init from from 'snabbdom-to-html/init'
+import AttrsModule from 'snabbdom-to-html/modules/attributes'
+import StyeModule from 'snabbdom-to-html/modules/style'
import {transposeVTree} from './transposition'

function makeBogusSelect() {
  return function select() {
    return {
      observable: Rx.Observable.empty(),
      events() {
        return Rx.Observable.empty()
      },
    }
  }
}

+const defaultModules = [
+  AttrsModules, StyleModule,
+]

-function makeHTMLDriver() {
+function makeHTMLDriver({modules = defaultModules} = {modules: defaultModules})
+  const toHTML = init(modules)
  return function htmlDriver(vtree$) {
    let output$ = vtree$.flatMapLatest(transposeVTree).last().map(toHTML)
    output$.select = makeBogusSelect()
    return output$
  }
}

export {makeHTMLDriver}

TylorS avatar Feb 01 '16 16:02 TylorS

Also need to add something to the documentation for this

TylorS avatar Feb 01 '16 16:02 TylorS