Skip to content

Commit 6119414

Browse files
committed
Fix #2893 for gh-pages, pending long-term fix
0 parents  commit 6119414

File tree

3,799 files changed

+708982
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,799 files changed

+708982
-0
lines changed

v0.1.1/auto-redrawing.html

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<title>Mithril</title>
5+
<link href="http://fonts.googleapis.com/css?family=Open+Sans:300italic" rel="stylesheet">
6+
<link href="lib/prism/prism.css" rel="stylesheet">
7+
<link href="style.css" rel="stylesheet">
8+
</head>
9+
<body>
10+
<header>
11+
<nav class="container">
12+
<a href="index.html" class="logo"><span>&#9675;</span> Mithril</a>
13+
<a href="getting-started.html">Guide</a>
14+
<a href="mithril.html">API</a>
15+
<a href="mithril.min.zip">Download</a>
16+
<a href="http://github.com/lhorie/mithril.js" target="_blank">Github</a>
17+
</nav>
18+
<div class="deprecated">
19+
WARNING: This documentation is for an old version of mithril!
20+
Please see the <a href="https://mithril.js.org/">current docs</a> for more accurate info.
21+
</div></header>
22+
<main>
23+
<section class="content">
24+
<div class="container">
25+
<div class="row">
26+
<div class="col(3,3,12)">
27+
<h2 id="core-topics">Core Topics</h2>
28+
<ul>
29+
<li><a href="installation.html">Installation</a></li>
30+
<li><a href="getting-started.html">Getting Started</a></li>
31+
<li><a href="routing.html">Routing</a></li>
32+
<li><a href="web-services.html">Web Services</a></li>
33+
<li><a href="components.html">Components</a></li>
34+
</ul>
35+
<h2 id="advanced-topics.html">Advanced Topics</h2>
36+
<ul>
37+
<li><a href="compiling-templates.html">Compiling Templates</a></li>
38+
<li><a href="auto-redrawing.html">The Auto-Redrawing System</a></li>
39+
<li><a href="integration.html">Integrating with Other Libraries</a></li>
40+
</ul>
41+
<h2 id="misc">Misc</h2>
42+
<ul>
43+
<li><a href="comparison.html">Differences from Other MVC Frameworks</a></li>
44+
<li><a href="practices.html">Good Practices</a></li>
45+
<li><a href="tools.html">Useful Tools</a></li>
46+
</ul>
47+
</div>
48+
<div class="col(9,9,12)">
49+
<h2 id="integrating-with-the-auto-redrawing-system">Integrating with The Auto-Redrawing System</h2>
50+
<p>If you need to do custom asynchronous calls without using Mithril&#39;s API, and find that your views are not redrawing, or that you&#39;re being forced to call <a href="mithril.redraw.html"><code>m.redraw</code></a> manually, you should consider using <code>m.startComputation</code> / <code>m.endComputation</code> so that Mithril can intelligently auto-redraw once your custom code finishes running.</p>
51+
<p>In order to integrate asynchronous code to Mithril&#39;s autoredrawing system, you should call <code>m.startComputation</code> BEFORE making an asynchronous call, and <code>m.endComputation</code> after the asynchronous callback completes.</p>
52+
<pre><code class="lang-javascript">//this service waits 1 second, logs &quot;hello&quot; and then notifies the view that
53+
//it may start redrawing (if no other asynchronous operations are pending)
54+
var doStuff = function() {
55+
m.startComputation(); //call `startComputation` before the asynchronous `setTimeout`
56+
57+
setTimeout(function() {
58+
console.log(&quot;hello&quot;);
59+
60+
m.endComputation(); //call `endComputation` at the end of the callback
61+
}, 1000);
62+
};</code></pre>
63+
<p>To integrate synchronous code, call <code>m.startComputation</code> at the beginning of the method, and <code>m.endComputation</code> at the end.</p>
64+
<pre><code class="lang-javascript">window.onfocus = function() {
65+
m.startComputation(); //call before everything else in the event handler
66+
67+
doStuff();
68+
69+
m.endComputation(); //call after everything else in the event handler
70+
}</code></pre>
71+
<p>For each <code>m.startComputation</code> call a library makes, it MUST also make one and ONLY one corresponding <code>m.endComputation</code> call.</p>
72+
<p>You should not use these methods if your code is intended to run repeatedly (e.g. by using <code>setInterval</code>). If you want to repeatedly redraw the view without necessarily waiting for user input, you should manually call <a href="mithril.redraw.html"><code>m.redraw</code></a> within the repeatable context.</p>
73+
<hr>
74+
<h3 id="integrating-multiple-execution-threads">Integrating multiple execution threads</h3>
75+
<p>When <a href="integration.html">integrating with third party libraries</a>, you might find that you need to call asynchronous methods from outside of Mithril&#39;s API.</p>
76+
<p>In order to integrate non-trivial asynchronous code to Mithril&#39;s auto-redrawing system, you need to ensure all execution threads call <code>m.startComputation</code> / <code>m.endComputation</code>.</p>
77+
<p>An execution thread is basically any amount of code that runs before other asynchronous threads start to run.</p>
78+
<p>Integrating multiple execution threads can be done in a two different ways: in a layered fashion or in comprehensive fashion</p>
79+
<h4 id="layered-integration">Layered integration</h4>
80+
<p>Layered integration is recommended for modular code where many different APIs may be put together at the application level.</p>
81+
<p>Below is an example where various methods implemented with a third party library can be integrated in layered fashion: any of the methods can be used in isolation or in combination.</p>
82+
<p>Notice how <code>doBoth</code> repeatedly calls <code>m.startComputation</code> since that method calls both <code>doSomething</code> and <code>doAnother</code>. This is perfectly valid: there are three asynchronous computations pending after the <code>jQuery.when</code> method is called, and therefore, three pairs of <code>m.startComputation</code> / <code>m.endComputation</code> in play.</p>
83+
<pre><code class="lang-javascript">var doSomething = function(callback) {
84+
m.startComputation(); //call `startComputation` before the asynchronous AJAX request
85+
86+
return jQuery.ajax(&quot;/something&quot;).done(function() {
87+
if (callback) callback();
88+
89+
m.endComputation(); //call `endComputation` at the end of the callback
90+
});
91+
};
92+
var doAnother = function(callback) {
93+
m.startComputation(); //call `startComputation` before the asynchronous AJAX request
94+
95+
return jQuery.ajax(&quot;/another&quot;).done(function() {
96+
if (callback) callback();
97+
m.endComputation(); //call `endComputation` at the end of the callback
98+
});
99+
};
100+
var doBoth = function(callback) {
101+
m.startComputation(); //call `startComputation` before the asynchronous synchronization method
102+
103+
jQuery.when(doSomething(), doAnother()).then(function() {
104+
if (callback) callback();
105+
106+
m.endComputation(); //call `endComputation` at the end of the callback
107+
})
108+
};</code></pre>
109+
<h4 id="comprehensive-integration">Comprehensive integration</h4>
110+
<p>Comprehensive integration is recommended if integrating a monolithic series of asynchronous operations. In contrast to layered integration, it minimizes the number of <code>m.startComputation</code> / <code>m.endComputation</code> to avoid clutter.</p>
111+
<p>The example below shows a convoluted series of AJAX requests implemented with a third party library.</p>
112+
<pre><code class="lang-javascript">var doSomething = function(callback) {
113+
m.startComputation(); //call `startComputation` before everything else
114+
115+
jQuery.ajax(&quot;/something&quot;).done(function() {
116+
doStuff();
117+
jQuery.ajax(&quot;/another&quot;).done(function() {
118+
doMoreStuff();
119+
jQuery.ajax(&quot;/more&quot;).done(function() {
120+
if (callback) callback();
121+
122+
m.endComputation(); //call `endComputation` at the end of everything
123+
});
124+
});
125+
});
126+
};</code></pre>
127+
128+
</div>
129+
</div>
130+
</div>
131+
</section>
132+
</main>
133+
<footer>
134+
<div class="container">
135+
Released under the <a href="http://opensource.org/licenses/MIT" target="_blank">MIT license</a>
136+
<br>&copy; 2014 Leo Horie
137+
</div>
138+
</footer>
139+
<script src="lib/prism/prism.js"></script>
140+
</body>
141+
</html>

v0.1.1/change-log.html

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<title>Mithril</title>
5+
<link href="http://fonts.googleapis.com/css?family=Open+Sans:300italic" rel="stylesheet">
6+
<link href="lib/prism/prism.css" rel="stylesheet">
7+
<link href="style.css" rel="stylesheet">
8+
</head>
9+
<body>
10+
<header>
11+
<nav class="container">
12+
<a href="index.html" class="logo"><span>&#9675;</span> Mithril</a>
13+
<a href="getting-started.html">Guide</a>
14+
<a href="mithril.html">API</a>
15+
<a href="mithril.min.zip">Download</a>
16+
<a href="http://github.com/lhorie/mithril.js" target="_blank">Github</a>
17+
</nav>
18+
<div class="deprecated">
19+
WARNING: This documentation is for an old version of mithril!
20+
Please see the <a href="https://mithril.js.org/">current docs</a> for more accurate info.
21+
</div></header>
22+
<main>
23+
<section class="content">
24+
<div class="container">
25+
<div class="row">
26+
<div class="col(3,3,12)">
27+
<h2 id="api">API (v0.1.1)</h2>
28+
<h3 id="core">Core</h3>
29+
<ul>
30+
<li><a href="mithril.html">m</a></li>
31+
<li><a href="mithril.prop.html">m.prop</a></li>
32+
<li><a href="mithril.withAttr.html">m.withAttr</a></li>
33+
<li><a href="mithril.module.html">m.module</a></li>
34+
<li><a href="mithril.trust.html">m.trust</a></li>
35+
<li><a href="mithril.render.html">m.render</a></li>
36+
<li><a href="mithril.redraw.html">m.redraw</a></li>
37+
</ul>
38+
<h3 id="routing">Routing</h3>
39+
<ul>
40+
<li><a href="mithril.route.html">m.route</a>
41+
<ul>
42+
<li><a href="mithril.route.html#defining-routes">m.route(rootElement, defaultRoute, routes)</a></li>
43+
<li><a href="mithril.route.html#redirecting">m.route(path)</a></li>
44+
<li><a href="mithril.route.html#mode-abstraction">m.route(element)</a></li>
45+
<li><a href="mithril.route.html#mode">m.route.mode</a></li>
46+
<li><a href="mithril.route.html#param">m.route.param</a></li>
47+
</ul>
48+
</li>
49+
</ul>
50+
<h3 id="data">Data</h3>
51+
<ul>
52+
<li><a href="mithril.request.html">m.request</a></li>
53+
<li><a href="mithril.deferred.html">m.deferred</a></li>
54+
<li><a href="mithril.sync.html">m.sync</a></li>
55+
<li><a href="mithril.computation.html">m.startComputation / m.endComputation</a></li>
56+
</ul>
57+
58+
<h2 id="archive">History</h2>
59+
<ul>
60+
<li><a href="roadmap.html">Roadmap</a></li>
61+
<li><a href="change-log.html">Change log</a></li>
62+
</ul>
63+
</div>
64+
<div class="col(9,9,12)">
65+
<h2 id="change-log">Change Log</h2>
66+
<p><a href="/mithril/archive/v0.1.1">v0.1.1</a> - maintenance</p>
67+
<h3 id="news-">News:</h3>
68+
<ul>
69+
<li>Mithril is now available at <a href="http://cdnjs.com/libraries/mithril/">cdnjs</a> and <a href="http://www.jsdelivr.com/#!mithril">jsdelivr</a></li>
70+
</ul>
71+
<h3 id="bug-fixes-">Bug Fixes:</h3>
72+
<ul>
73+
<li><code>m.route.param</code> now resets on route change correctly <a href="https://github.com/lhorie/mithril.js/issues/15">#15</a></li>
74+
<li><code>m.render</code> now correctly ignores undefined values in the virtual tree<a href="https://github.com/lhorie/mithril.js/issues/16">#16</a></li>
75+
<li>errors thrown in promises now cause downstreams to be rejected <a href="https://github.com/lhorie/mithril.js/issues/1">#1</a></li>
76+
</ul>
77+
<h3 id="breaking-changes-">Breaking changes:</h3>
78+
<ul>
79+
<li><p>changed default value for <code>xhr.withCredentials</code> from <code>true</code> to <code>false</code> for <code>m.request</code>, since public APIs are more common than auth-walled ones. <a href="https://github.com/lhorie/mithril.js/issues/14">#14</a></p>
80+
<p>In order to configure this flag, the following configuration should be used:</p>
81+
<pre><code class="lang-javascript">var privateAPI = function(xhr) {xhr.withCredentials = true};
82+
83+
m.request({method: &quot;GET&quot;, url: &quot;http://foo.com/api&quot;, config: privateAPI});</code></pre>
84+
</li>
85+
</ul>
86+
<hr>
87+
<p><a href="/mithril/archive/v0.1">v0.1</a> - Initial release</p>
88+
89+
</div>
90+
</div>
91+
</div>
92+
</section>
93+
</main>
94+
<footer>
95+
<div class="container">
96+
Released under the <a href="http://opensource.org/licenses/MIT" target="_blank">MIT license</a>
97+
<br>&copy; 2014 Leo Horie
98+
</div>
99+
</footer>
100+
<script src="lib/prism/prism.js"></script>
101+
</body>
102+
</html>

0 commit comments

Comments
 (0)