byo
byo
or bring your own
is like choo without a renderer.
Example
Clone of the choo example, but we bring bel, nanomount, and nanomorph ourselves.
var byo = var html = var nanomount = var nanomorph = var app = appappappapp { return root} { return } { return html` count is Increment ` { }} { emitter} { statecount = 0 emitter}
API
Under the hood, byo
is essentially a fork of choo
. At the moment, we'll keep byo
in API parity with choo
. Please refer to the choo documentation for details on routing, events, and the architecture in general. The only thing we need to document here is...
Additional Options
A couple additional options are provided for defining render methods, alongside all the supported choo
options. While we refer to them as options, mount
and render
are required since byo has no render methods by default.
opts.mount
required | Mount the tree onto the root. Typically you will return the tree
or root
. Example:
{ return root}
opts.render
required | Render the new tree. tree
, newTree
, and root
are available for morphing. Example:
{ return }
opts.toString
Convert html (or vdom) to string. You'll usually define this method for server rendering. Example:
{ return html}
Why does this exist?
If you like choo
use choo
, it's rad.
But sometimes bel
, nanomount
, or nanomorph
might not fit the needs of a project. Maybe you like virtual dom but you still want to build your apps choo
-style. byo
is the back-pocket tool for those scenarios. I'm maintaining this project because I currently have a need for nested components which we can't quite yet pull off with nanocomponent, so I opt for preact + hyperx.
Renderers
Here are some examples of renderers with tagged template string implementations you can byo
:
var vdom = var hyperx = var html = var rootNode { rootNode = vdom root return tree}) { var patches = vdom rootNode = vdom return newTree})
var Inferno = var hyperx = var html = { return Inferno}) { return Inferno})
var preact = var hyperx = var html = { return preact}) { return preact})
var React = var ReactDOM = var hyperx = var html = { return ReactDOM}) { return ReactDOM})
var html = { html return tree}) { html return newTree})
Fine Print
Thanks Yoshua Wuyts and the rest of the choo team (s/o dat) for the continual awsm work 🙏