From 4e9505335cac0f79f19a352171b1a51d048f48f9 Mon Sep 17 00:00:00 2001 From: Pat Cavit Date: Mon, 5 Dec 2016 11:41:20 -0800 Subject: [PATCH 1/2] Fix TOC link, remove m.request.run ref (#1456) --- docs/route.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/route.md b/docs/route.md index b16d1336..1abaea30 100644 --- a/docs/route.md +++ b/docs/route.md @@ -258,7 +258,7 @@ m.route(document.body, "/edit/pictures/image.jpg", { --- -### Changing route prefix +### Changing router prefix The router prefix is a fragment of the URL that dictates the underlying [strategy](routing-strategies.md) used by the router. @@ -402,14 +402,12 @@ module.export = { ```javascript // index.js function load(file, done) { - m.request({ - method: "GET", - url: file, + m.request(file, { extract: function(xhr) { return new Function("var module = {};" + xhr.responseText + ";return module.exports;") } }) - .run(done) + .then(done) } m.route(document.body, "/", { From bc14b0568d50beeb9cf90d01a9908ea45a47b2cb Mon Sep 17 00:00:00 2001 From: Barney Carroll Date: Tue, 6 Dec 2016 01:20:17 +0000 Subject: [PATCH 2/2] Migration docs: elaborate on changes in redraw logic (#1440) * Migration docs: elaborate on changes in redraw logic * Removed bad m.request().then(m.redraw) docs --- docs/change-log.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/change-log.md b/docs/change-log.md index 2698ad9d..ea2ee425 100644 --- a/docs/change-log.md +++ b/docs/change-log.md @@ -13,7 +13,9 @@ If you are migrating, consider using the [mithril-codemods](https://www.npmjs.co - [`m.prop` removed](#mprop-removed) - [`m.component` removed](#mcomponent-removed) - [`config` function](#config-function) -- [Cancelling redraw from event handlers](#cancelling-redraw-from-event-handlers) +- [Changes in redraw behaviour](#changes-in-redraw-behaviour) + - [No more redraw locks](#no-more-redraw-locks) + - [Cancelling redraw from event handlers](#cancelling-redraw-from-event-handlers) - [Component `controller` function](#component-controller-function) - [Component arguments](#component-arguments) - [`view()` parameters](#view-parameters) @@ -118,7 +120,15 @@ If available the DOM-Element of the vnode can be accessed at `vnode.dom`. --- -## Cancelling redraw from event handlers +## Changes in redraw behaviour + +Mithril's rendering engine still operates on the basis of semi-automated global redraws, but some APIs and behaviours differ: + +### No more redraw locks + +In v0.2.x, Mithril allowed 'redraw locks' which temporarily prevented blocked draw logic: by default, `m.request` would lock the draw loop on execution and unlock when all pending requests had resolved - the same behaviour could be invoked manually using `m.startComputation()` and `m.endComputation()`. The latter APIs and the associated behaviour has been removed in v1.x. Redraw locking can lead to buggy UIs: the concerns of one part of the application should not be allowed to prevent other parts of the view from updating to reflect change. + +### Cancelling redraw from event handlers `m.mount()` and `m.route()` still automatically redraw after a DOM event handler runs. Cancelling these redraws from within your event handlers is now done by setting the `redraw` property on the passed-in event object to `false`.