diff --git a/archive/v0.1.3/change-log.html b/archive/v0.1.3/change-log.html index d0ac7884..370f6374 100644 --- a/archive/v0.1.3/change-log.html +++ b/archive/v0.1.3/change-log.html @@ -60,6 +60,13 @@
v0.1.3 - maintenance
+style attributes and event handlersm.deferred().promise now causes the promise to adopt its state v0.1.2 - maintenance
For the most part, Mithril promises behave as you'd expect a Promise/A+ promise to behave, but with a few key differences:
+Mithril promises forward a value downstream if a resolution callback returns undefined. This allows simpler debugging of promise chains:
var data = m.request({method: "GET", url: "/data"})
+ .then(console.log) //Mithril promises let us debug like this
+ .then(doStuff)
+
+var data = m.request({method: "GET", url: "/data"})
+ .then(function(value) { // Promises/A+ would require us to declare an anonymous function
+ console.log(value) // here's the debugging snippet
+ return value // and we need to remember to return the value as well
+ })
+ .then(doStuff) // or else `doStuff` will break
+Another subtle difference is that the Promises/A+ require a callback to run in a different execution context than its respective then method. This requirement exists to support an obscure edge cases and incurs a significant performance hit on each link of a promise chain. To be more specific, the performance hit can come either in the form of a 4ms minimum delay (if the implementation uses setTimeout), or from having to load a bunch of hacky polyfill code for a feature that is not being considered for addition by some browser vendors.
To illustrate the difference between Mithril and A+ promises, consider the code below:
+var deferred = m.deferred()
+
+deferred.promise.then(function() {
+ console.log(1)
+})
+
+deferred.resolve("value")
+
+console.log(2)
+In the example above, A+ promises are required to log 2 before logging 1, whereas Mithril logs 1 before 2. Typically resolve/reject are called asynchronously after the then method is called, so normally this difference does not matter.
Deferred deferred()
diff --git a/archive/v0.1.3/mithril.min.zip b/archive/v0.1.3/mithril.min.zip
index a1ab700e..f0ab5f55 100644
Binary files a/archive/v0.1.3/mithril.min.zip and b/archive/v0.1.3/mithril.min.zip differ
diff --git a/docs/change-log.md b/docs/change-log.md
index 98f6780c..002e1f81 100644
--- a/docs/change-log.md
+++ b/docs/change-log.md
@@ -1,5 +1,14 @@
## Change Log
+[v0.1.3](/mithril/archive/v0.1.3) - maintenance
+
+### Bug Fixes:
+
+- diff no longer touch the DOM when processing `style` attributes and event handlers
+- returning a thennable to a resolution callback in `m.deferred().promise` now causes the promise to adopt its state
+
+---
+
[v0.1.2](/mithril/archive/v0.1.2) - maintenance
### News:
diff --git a/docs/mithril.deferred.md b/docs/mithril.deferred.md
index daa19b53..4c3aa920 100644
--- a/docs/mithril.deferred.md
+++ b/docs/mithril.deferred.md
@@ -29,6 +29,46 @@ greetAsync()
---
+### Differences from Promises/A+
+
+For the most part, Mithril promises behave as you'd expect a [Promise/A+](http://promises-aplus.github.io/promises-spec/) promise to behave, but with a few key differences:
+
+Mithril promises forward a value downstream if a resolution callback returns `undefined`. This allows simpler debugging of promise chains:
+
+```javascript
+var data = m.request({method: "GET", url: "/data"})
+ .then(console.log) //Mithril promises let us debug like this
+ .then(doStuff)
+
+var data = m.request({method: "GET", url: "/data"})
+ .then(function(value) { // Promises/A+ would require us to declare an anonymous function
+ console.log(value) // here's the debugging snippet
+ return value // and we need to remember to return the value as well
+ })
+ .then(doStuff) // or else `doStuff` will break
+
+```
+
+Another subtle difference is that the Promises/A+ require a callback to run in a different execution context than its respective `then` method. This requirement exists to support an obscure edge cases and incurs [a significant performance hit on each link of a promise chain](http://thanpol.as/javascript/promises-a-performance-hits-you-should-be-aware-of/). To be more specific, the performance hit can come either in the form of a 4ms minimum delay (if the implementation uses `setTimeout`), or from having to load a [bunch of hacky polyfill code](https://raw.githubusercontent.com/NobleJS/setImmediate/master/setImmediate.js) for a [feature that is not being considered for addition by some browser vendors](https://developer.mozilla.org/en-US/docs/Web/API/Window.setImmediate).
+
+To illustrate the difference between Mithril and A+ promises, consider the code below:
+
+```javascript
+var deferred = m.deferred()
+
+deferred.promise.then(function() {
+ console.log(1)
+})
+
+deferred.resolve("value")
+
+console.log(2)
+```
+
+In the example above, A+ promises are required to log `2` before logging `1`, whereas Mithril logs `1` before `2`. Typically `resolve`/`reject` are called asynchronously after the `then` method is called, so normally this difference does not matter.
+
+---
+
### Signature
[How to read signatures](how-to-read-signatures.md)