@erickmerchant/framework
Advanced tools
Comparing version 5.0.1 to 6.0.0
@@ -13,7 +13,9 @@ 'use strict'; | ||
var context = {}; | ||
var href = void 0; | ||
var state = store(); | ||
var show = singlePage(function (href) { | ||
context.href = href; | ||
var rafCalled = false; | ||
var show = singlePage(function (newHref) { | ||
href = newHref; | ||
render(); | ||
@@ -25,13 +27,19 @@ }); | ||
function dispatch() { | ||
render.apply(undefined, arguments); | ||
state = store.apply(undefined, [state].concat(Array.prototype.slice.call(arguments))); | ||
render(); | ||
} | ||
function render() { | ||
state = store.apply(undefined, [state].concat(Array.prototype.slice.call(arguments))); | ||
if (!rafCalled) { | ||
rafCalled = true; | ||
window.requestAnimationFrame(function () { | ||
var element = component({ state: state, dispatch: dispatch, context: context, show: show, html: html, next: next }); | ||
window.requestAnimationFrame(function () { | ||
rafCalled = false; | ||
diffhtml.innerHTML(target, element); | ||
}); | ||
var element = component(href)({ state: state, dispatch: dispatch, show: show, html: html, next: next }); | ||
diffhtml.innerHTML(target, element); | ||
}); | ||
} | ||
} | ||
@@ -38,0 +46,0 @@ |
26
main.js
@@ -7,7 +7,9 @@ const catchLinks = require('catch-links') | ||
module.exports = function ({target, store, component}) { | ||
let context = {} | ||
let href | ||
let state = store() | ||
const show = singlePage(function (href) { | ||
context.href = href | ||
let rafCalled = false | ||
const show = singlePage(function (newHref) { | ||
href = newHref | ||
render() | ||
@@ -19,13 +21,19 @@ }) | ||
function dispatch () { | ||
render(...arguments) | ||
state = store(state, ...arguments) | ||
render() | ||
} | ||
function render () { | ||
state = store(state, ...arguments) | ||
if (!rafCalled) { | ||
rafCalled = true | ||
window.requestAnimationFrame(() => { | ||
const element = component({state, dispatch, context, show, html, next}) | ||
window.requestAnimationFrame(() => { | ||
rafCalled = false | ||
diffhtml.innerHTML(target, element) | ||
}) | ||
const element = component(href)({state, dispatch, show, html, next}) | ||
diffhtml.innerHTML(target, element) | ||
}) | ||
} | ||
} | ||
@@ -32,0 +40,0 @@ |
{ | ||
"name": "@erickmerchant/framework", | ||
"version": "5.0.1", | ||
"version": "6.0.0", | ||
"description": "A simple data down, actions up framework.", | ||
@@ -5,0 +5,0 @@ "main": "dist/main.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3722
74