Last active
April 11, 2017 23:42
-
-
Save jongacnik/171850792f3431fa85cf43f7f34b1955 to your computer and use it in GitHub Desktop.
choo renderers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Inferno = require('inferno') | |
var hyperx = require('hyperx') | |
var html = hyperx(require('inferno-create-element')) | |
function infernoRenderer (state, emit, renderer) { | |
renderer.render = function (tree, newTree, root) { | |
return Inferno.render(newTree, root) | |
} | |
renderer.mount = function (tree, root) { | |
return Inferno.render(tree, root) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var preact = require('preact') | |
var hyperx = require('hyperx') | |
var html = hyperx(preact.h) | |
function preactRenderer (state, emit, renderer) { | |
renderer.render = function (tree, newTree, root) { | |
return preact.render(newTree, root, tree) | |
} | |
renderer.mount = function (tree, root) { | |
return preact.render(tree, root) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var React = require('react') | |
var ReactDOM = require('react-dom') | |
var hyperx = require('hyperx') | |
var html = hyperx(React.createElement) | |
function reactRenderer (state, emit, renderer) { | |
renderer.render = function (tree, newTree, root) { | |
return ReactDOM.render(newTree, root) | |
} | |
renderer.mount = function (tree, root) { | |
return ReactDOM.render(tree, root) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var html = require('snabby') | |
function snabbyRenderer (state, emit, renderer) { | |
renderer.render = function (tree, newTree, root) { | |
html.update(tree, newTree) | |
return newTree | |
} | |
renderer.mount = function (tree, root) { | |
html.update(root, tree) | |
return tree | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var vdom = require('virtual-dom') | |
var hyperx = require('hyperx') | |
var html = hyperx(vdom.h) | |
var rootNode | |
function vdomRenderer (state, emit, renderer) { | |
renderer.render = function (tree, newTree, root) { | |
var patches = vdom.diff(tree, newTree) | |
rootNode = vdom.patch(rootNode, patches) | |
return newTree | |
} | |
renderer.mount = function (tree, root) { | |
rootNode = vdom.create(tree) | |
root.appendChild(rootNode) | |
return tree | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment