@erickmerchant/framework
Advanced tools
Comparing version 4.0.1 to 5.0.0
@@ -13,7 +13,8 @@ 'use strict'; | ||
var href = void 0; | ||
var show = singlePage(function (h) { | ||
href = h; | ||
var context = {}; | ||
var state = store(); | ||
var show = singlePage(function (href) { | ||
context.href = href; | ||
render(store()); | ||
render(); | ||
}); | ||
@@ -24,14 +25,20 @@ | ||
function dispatch() { | ||
render(store.apply(undefined, arguments)); | ||
render.apply(undefined, arguments); | ||
} | ||
function render(state) { | ||
var element = component({ state: state, dispatch: dispatch, href: href, show: show, html: html, next: next }); | ||
function render() { | ||
state = store.apply(undefined, [state].concat(Array.prototype.slice.call(arguments))); | ||
diffhtml.innerHTML(target, element); | ||
window.requestAnimationFrame(function () { | ||
var element = component({ state: state, dispatch: dispatch, context: context, show: show, html: html, next: next }); | ||
diffhtml.innerHTML(target, element); | ||
}); | ||
} | ||
}; | ||
function next(callback) { | ||
process.nextTick(callback); | ||
} | ||
function next(callback) { | ||
process.nextTick(function () { | ||
callback(target); | ||
}); | ||
} | ||
}; |
29
main.js
@@ -7,7 +7,8 @@ const catchLinks = require('catch-links') | ||
module.exports = function ({target, store, component}) { | ||
let href | ||
const show = singlePage(function (h) { | ||
href = h | ||
let context = {} | ||
let state = store() | ||
const show = singlePage(function (href) { | ||
context.href = href | ||
render(store()) | ||
render() | ||
}) | ||
@@ -18,14 +19,20 @@ | ||
function dispatch () { | ||
render(store(...arguments)) | ||
render(...arguments) | ||
} | ||
function render (state) { | ||
const element = component({state, dispatch, href, show, html, next}) | ||
function render () { | ||
state = store(state, ...arguments) | ||
diffhtml.innerHTML(target, element) | ||
window.requestAnimationFrame(() => { | ||
const element = component({state, dispatch, context, show, html, next}) | ||
diffhtml.innerHTML(target, element) | ||
}) | ||
} | ||
} | ||
function next (callback) { | ||
process.nextTick(callback) | ||
function next (callback) { | ||
process.nextTick(function () { | ||
callback(target) | ||
}) | ||
} | ||
} |
{ | ||
"name": "@erickmerchant/framework", | ||
"version": "4.0.1", | ||
"version": "5.0.0", | ||
"description": "A simple data down, actions up framework.", | ||
@@ -5,0 +5,0 @@ "main": "dist/main.js", |
3559
64