ovto 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/CHANGELOG.md +9 -1
- data/Gemfile.lock +6 -6
- data/README.md +7 -5
- data/Rakefile +2 -0
- data/book/api/actions.md +2 -2
- data/book/api/app.md +6 -6
- data/book/api/component.md +6 -6
- data/book/guides/debugging.md +9 -0
- data/book/guides/tutorial.md +12 -12
- data/docs/api/Ovto.html +168 -20
- data/docs/api/Ovto/Actions.html +1 -1
- data/docs/api/Ovto/App.html +1 -1
- data/docs/api/Ovto/Component.html +1 -1
- data/docs/api/Ovto/Component/MoreThanOneNode.html +1 -1
- data/docs/api/Ovto/Runtime.html +1 -1
- data/docs/api/Ovto/State.html +1 -1
- data/docs/api/Ovto/State/MissingValue.html +1 -1
- data/docs/api/Ovto/State/UnknownKey.html +1 -1
- data/docs/api/Ovto/WiredActions.html +1 -1
- data/docs/api/_index.html +1 -1
- data/docs/api/actions.html +4 -4
- data/docs/api/app.html +8 -8
- data/docs/api/component.html +8 -8
- data/docs/api/fetch.html +392 -0
- data/docs/api/file.README.html +10 -8
- data/docs/api/index.html +10 -8
- data/docs/api/method_list.html +59 -35
- data/docs/api/state.html +2 -2
- data/docs/api/top-level-namespace.html +1 -1
- data/docs/gitbook/gitbook.js +2 -2
- data/docs/gitbook/theme.js +1 -1
- data/docs/guides/debugging.html +7 -2
- data/docs/guides/development.html +2 -2
- data/docs/guides/tutorial.html +14 -14
- data/docs/index.html +12 -68
- data/docs/search_index.json +1 -1
- data/{example → examples}/sinatra/Gemfile +0 -0
- data/{example → examples}/sinatra/Gemfile.lock +10 -22
- data/{example → examples}/sinatra/README.md +1 -1
- data/{example → examples}/sinatra/app.rb +0 -0
- data/{example → examples}/sinatra/config.ru +0 -9
- data/{example → examples}/sinatra/ovto/app.rb +2 -2
- data/{example → examples}/sinatra/public/style.css +0 -0
- data/{example → examples}/sinatra/public/todomvc-app-css_index.css +0 -0
- data/{example → examples}/sinatra/public/todomvc-common_base.css +0 -0
- data/{example → examples}/sinatra/views/index.erb +1 -1
- data/{example → examples}/static/Gemfile +0 -0
- data/{example → examples}/static/Gemfile.lock +2 -2
- data/{example → examples}/static/README.md +1 -1
- data/{example → examples}/static/Rakefile +0 -0
- data/{example → examples}/static/app.rb +2 -2
- data/{example → examples}/static/index.html +1 -1
- data/index.html +44 -0
- data/lib/ovto.rb +8 -0
- data/lib/ovto/app.rb +18 -1
- data/lib/ovto/component.rb +2 -1
- data/lib/ovto/version.rb +1 -1
- data/ovtologo.odg +0 -0
- data/ovtologo.png +0 -0
- data/website/screen.css +18 -0
- metadata +23 -19
- data/example/static/app.js +0 -24808
data/docs/api/Ovto/Actions.html
CHANGED
@@ -293,7 +293,7 @@
|
|
293
293
|
</div>
|
294
294
|
|
295
295
|
<div id="footer">
|
296
|
-
Generated on
|
296
|
+
Generated on Mon Dec 24 21:23:44 2018 by
|
297
297
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
298
298
|
0.9.16 (ruby-2.5.3).
|
299
299
|
</div>
|
data/docs/api/Ovto/App.html
CHANGED
@@ -610,7 +610,7 @@
|
|
610
610
|
</div>
|
611
611
|
|
612
612
|
<div id="footer">
|
613
|
-
Generated on
|
613
|
+
Generated on Mon Dec 24 21:23:44 2018 by
|
614
614
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
615
615
|
0.9.16 (ruby-2.5.3).
|
616
616
|
</div>
|
@@ -340,7 +340,7 @@
|
|
340
340
|
</div>
|
341
341
|
|
342
342
|
<div id="footer">
|
343
|
-
Generated on
|
343
|
+
Generated on Mon Dec 24 21:23:44 2018 by
|
344
344
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
345
345
|
0.9.16 (ruby-2.5.3).
|
346
346
|
</div>
|
@@ -125,7 +125,7 @@
|
|
125
125
|
</div>
|
126
126
|
|
127
127
|
<div id="footer">
|
128
|
-
Generated on
|
128
|
+
Generated on Mon Dec 24 21:23:44 2018 by
|
129
129
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
130
130
|
0.9.16 (ruby-2.5.3).
|
131
131
|
</div>
|
data/docs/api/Ovto/Runtime.html
CHANGED
@@ -305,7 +305,7 @@
|
|
305
305
|
</div>
|
306
306
|
|
307
307
|
<div id="footer">
|
308
|
-
Generated on
|
308
|
+
Generated on Mon Dec 24 21:23:44 2018 by
|
309
309
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
310
310
|
0.9.16 (ruby-2.5.3).
|
311
311
|
</div>
|
data/docs/api/Ovto/State.html
CHANGED
@@ -842,7 +842,7 @@
|
|
842
842
|
</div>
|
843
843
|
|
844
844
|
<div id="footer">
|
845
|
-
Generated on
|
845
|
+
Generated on Mon Dec 24 21:23:44 2018 by
|
846
846
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
847
847
|
0.9.16 (ruby-2.5.3).
|
848
848
|
</div>
|
@@ -125,7 +125,7 @@
|
|
125
125
|
</div>
|
126
126
|
|
127
127
|
<div id="footer">
|
128
|
-
Generated on
|
128
|
+
Generated on Mon Dec 24 21:23:44 2018 by
|
129
129
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
130
130
|
0.9.16 (ruby-2.5.3).
|
131
131
|
</div>
|
@@ -125,7 +125,7 @@
|
|
125
125
|
</div>
|
126
126
|
|
127
127
|
<div id="footer">
|
128
|
-
Generated on
|
128
|
+
Generated on Mon Dec 24 21:23:44 2018 by
|
129
129
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
130
130
|
0.9.16 (ruby-2.5.3).
|
131
131
|
</div>
|
@@ -333,7 +333,7 @@
|
|
333
333
|
</div>
|
334
334
|
|
335
335
|
<div id="footer">
|
336
|
-
Generated on
|
336
|
+
Generated on Mon Dec 24 21:23:44 2018 by
|
337
337
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
338
338
|
0.9.16 (ruby-2.5.3).
|
339
339
|
</div>
|
data/docs/api/_index.html
CHANGED
@@ -221,7 +221,7 @@
|
|
221
221
|
</div>
|
222
222
|
|
223
223
|
<div id="footer">
|
224
|
-
Generated on
|
224
|
+
Generated on Mon Dec 24 21:23:44 2018 by
|
225
225
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
226
226
|
0.9.16 (ruby-2.5.3).
|
227
227
|
</div>
|
data/docs/api/actions.html
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
<title>Ovto::Actions · GitBook</title>
|
8
8
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
9
9
|
<meta name="description" content="">
|
10
|
-
<meta name="generator" content="GitBook 3.2.
|
10
|
+
<meta name="generator" content="GitBook 3.2.2">
|
11
11
|
|
12
12
|
|
13
13
|
|
@@ -312,7 +312,7 @@ the <code>Actions</code> class. Here is some more conventions:</p>
|
|
312
312
|
<span class="hljs-keyword">end</span>
|
313
313
|
<span class="hljs-keyword">end</span>
|
314
314
|
|
315
|
-
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">
|
315
|
+
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MainComponent</span> < Ovto::Component</span>
|
316
316
|
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">render</span><span class="hljs-params">(<span class="hljs-symbol">state:</span>)</span></span>
|
317
317
|
o <span class="hljs-string">'span'</span>, state.count
|
318
318
|
o <span class="hljs-string">'button'</span>, <span class="hljs-symbol">onclick:</span> ->{ actions.increment(<span class="hljs-symbol">by:</span> <span class="hljs-number">1</span>) }
|
@@ -320,7 +320,7 @@ the <code>Actions</code> class. Here is some more conventions:</p>
|
|
320
320
|
<span class="hljs-keyword">end</span>
|
321
321
|
<span class="hljs-keyword">end</span>
|
322
322
|
|
323
|
-
MyApp.run(<span class="hljs-symbol">id:</span> <span class="hljs-string">'ovto
|
323
|
+
MyApp.run(<span class="hljs-symbol">id:</span> <span class="hljs-string">'ovto'</span>)
|
324
324
|
</code></pre>
|
325
325
|
<h2 id="calling-actions">Calling actions</h2>
|
326
326
|
<p>Actions can be called from components via <code>actions</code> method. This is an instance of
|
@@ -394,7 +394,7 @@ In such cases, you can call another action via <code>actions</code> to tell Ovto
|
|
394
394
|
<script>
|
395
395
|
var gitbook = gitbook || [];
|
396
396
|
gitbook.push(function() {
|
397
|
-
gitbook.page.hasChanged({"page":{"title":"Ovto::Actions","level":"1.3.3","depth":2,"next":{"title":"Ovto::Component","level":"1.3.4","depth":2,"path":"api/component.md","ref":"api/component.md","articles":[]},"previous":{"title":"Ovto::State","level":"1.3.2","depth":2,"path":"api/state.md","ref":"api/state.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"api/actions.md","mtime":"2018-
|
397
|
+
gitbook.page.hasChanged({"page":{"title":"Ovto::Actions","level":"1.3.3","depth":2,"next":{"title":"Ovto::Component","level":"1.3.4","depth":2,"path":"api/component.md","ref":"api/component.md","articles":[]},"previous":{"title":"Ovto::State","level":"1.3.2","depth":2,"path":"api/state.md","ref":"api/state.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"api/actions.md","mtime":"2018-12-23T09:45:52.000Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2018-12-24T12:23:40.758Z"},"basePath":"..","book":{"language":""}});
|
398
398
|
});
|
399
399
|
</script>
|
400
400
|
</div>
|
data/docs/api/app.html
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
<title>Ovto::App · GitBook</title>
|
8
8
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
9
9
|
<meta name="description" content="">
|
10
|
-
<meta name="generator" content="GitBook 3.2.
|
10
|
+
<meta name="generator" content="GitBook 3.2.2">
|
11
11
|
|
12
12
|
|
13
13
|
|
@@ -289,7 +289,7 @@
|
|
289
289
|
|
290
290
|
<h1 id="ovtoapp">Ovto::App</h1>
|
291
291
|
<p>First of all, you need to define a subclass of <code>Ovto::App</code> and define <code>class State</code>,
|
292
|
-
<code>class Actions</code> and <code>class
|
292
|
+
<code>class Actions</code> and <code>class MainComponent</code> in it.</p>
|
293
293
|
<h2 id="example">Example</h2>
|
294
294
|
<p>This is a smallest Ovto app.</p>
|
295
295
|
<pre><code class="lang-rb"><span class="hljs-keyword">require</span> <span class="hljs-string">'opal'</span>
|
@@ -302,14 +302,14 @@
|
|
302
302
|
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Actions</span> < Ovto::Actions</span>
|
303
303
|
<span class="hljs-keyword">end</span>
|
304
304
|
|
305
|
-
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">
|
305
|
+
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MainComponent</span> < Ovto::Component</span>
|
306
306
|
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">render</span><span class="hljs-params">(<span class="hljs-symbol">state:</span>)</span></span>
|
307
307
|
o <span class="hljs-string">'input'</span>, <span class="hljs-symbol">type:</span> <span class="hljs-string">'button'</span>, <span class="hljs-symbol">value:</span> <span class="hljs-string">'Hello'</span>
|
308
308
|
<span class="hljs-keyword">end</span>
|
309
309
|
<span class="hljs-keyword">end</span>
|
310
310
|
<span class="hljs-keyword">end</span>
|
311
311
|
|
312
|
-
MyApp.run(<span class="hljs-symbol">id:</span> <span class="hljs-string">'ovto
|
312
|
+
MyApp.run(<span class="hljs-symbol">id:</span> <span class="hljs-string">'ovto'</span>)
|
313
313
|
</code></pre>
|
314
314
|
<p>It renders a button and does nothing else. Let's have some fun:</p>
|
315
315
|
<pre><code class="lang-rb"><span class="hljs-keyword">require</span> <span class="hljs-string">'opal'</span>
|
@@ -329,7 +329,7 @@ MyApp.run(<span class="hljs-symbol">id:</span> <span class="hljs-string">'o
|
|
329
329
|
<span class="hljs-keyword">end</span>
|
330
330
|
<span class="hljs-keyword">end</span>
|
331
331
|
|
332
|
-
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">
|
332
|
+
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MainComponent</span> < Ovto::Component</span>
|
333
333
|
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">render</span><span class="hljs-params">(<span class="hljs-symbol">state:</span>)</span></span>
|
334
334
|
o <span class="hljs-string">'input'</span>, {
|
335
335
|
<span class="hljs-symbol">type:</span> <span class="hljs-string">'button'</span>,
|
@@ -341,7 +341,7 @@ MyApp.run(<span class="hljs-symbol">id:</span> <span class="hljs-string">'o
|
|
341
341
|
<span class="hljs-keyword">end</span>
|
342
342
|
<span class="hljs-keyword">end</span>
|
343
343
|
|
344
|
-
MyApp.run(<span class="hljs-symbol">id:</span> <span class="hljs-string">'ovto
|
344
|
+
MyApp.run(<span class="hljs-symbol">id:</span> <span class="hljs-string">'ovto'</span>)
|
345
345
|
</code></pre>
|
346
346
|
<p>Here we added <code>color_idx</code> to app state and <code>update_color</code> action to change it.
|
347
347
|
The button is updated to have the color indicated by <code>color_idx</code> and
|
@@ -357,7 +357,7 @@ now has <code>onclick</code> event handler which executes the action.</p>
|
|
357
357
|
...
|
358
358
|
<span class="hljs-keyword">end</span>
|
359
359
|
|
360
|
-
MyApp.run(<span class="hljs-symbol">id:</span> <span class="hljs-string">'ovto
|
360
|
+
MyApp.run(<span class="hljs-symbol">id:</span> <span class="hljs-string">'ovto'</span>)
|
361
361
|
</code></pre>
|
362
362
|
|
363
363
|
|
@@ -398,7 +398,7 @@ MyApp.run(<span class="hljs-symbol">id:</span> <span class="hljs-string">'o
|
|
398
398
|
<script>
|
399
399
|
var gitbook = gitbook || [];
|
400
400
|
gitbook.push(function() {
|
401
|
-
gitbook.page.hasChanged({"page":{"title":"Ovto::App","level":"1.3.1","depth":2,"next":{"title":"Ovto::State","level":"1.3.2","depth":2,"path":"api/state.md","ref":"api/state.md","articles":[]},"previous":{"title":"API","level":"1.3","depth":1,"ref":"","articles":[{"title":"Ovto::App","level":"1.3.1","depth":2,"path":"api/app.md","ref":"api/app.md","articles":[]},{"title":"Ovto::State","level":"1.3.2","depth":2,"path":"api/state.md","ref":"api/state.md","articles":[]},{"title":"Ovto::Actions","level":"1.3.3","depth":2,"path":"api/actions.md","ref":"api/actions.md","articles":[]},{"title":"Ovto::Component","level":"1.3.4","depth":2,"path":"api/component.md","ref":"api/component.md","articles":[]},{"title":"Ovto.fetch","level":"1.3.5","depth":2,"path":"api/fetch.md","ref":"api/fetch.md","articles":[]}]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"api/app.md","mtime":"2018-
|
401
|
+
gitbook.page.hasChanged({"page":{"title":"Ovto::App","level":"1.3.1","depth":2,"next":{"title":"Ovto::State","level":"1.3.2","depth":2,"path":"api/state.md","ref":"api/state.md","articles":[]},"previous":{"title":"API","level":"1.3","depth":1,"ref":"","articles":[{"title":"Ovto::App","level":"1.3.1","depth":2,"path":"api/app.md","ref":"api/app.md","articles":[]},{"title":"Ovto::State","level":"1.3.2","depth":2,"path":"api/state.md","ref":"api/state.md","articles":[]},{"title":"Ovto::Actions","level":"1.3.3","depth":2,"path":"api/actions.md","ref":"api/actions.md","articles":[]},{"title":"Ovto::Component","level":"1.3.4","depth":2,"path":"api/component.md","ref":"api/component.md","articles":[]},{"title":"Ovto.fetch","level":"1.3.5","depth":2,"path":"api/fetch.md","ref":"api/fetch.md","articles":[]}]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"api/app.md","mtime":"2018-12-23T09:45:52.000Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2018-12-24T12:23:40.758Z"},"basePath":"..","book":{"language":""}});
|
402
402
|
});
|
403
403
|
</script>
|
404
404
|
</div>
|
data/docs/api/component.html
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
<title>Ovto::Component · GitBook</title>
|
8
8
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
9
9
|
<meta name="description" content="">
|
10
|
-
<meta name="generator" content="GitBook 3.2.
|
10
|
+
<meta name="generator" content="GitBook 3.2.2">
|
11
11
|
|
12
12
|
|
13
13
|
|
@@ -290,11 +290,11 @@
|
|
290
290
|
<section class="normal markdown-section">
|
291
291
|
|
292
292
|
<h1 id="ovtocomponent">Ovto::Component</h1>
|
293
|
-
<p>
|
293
|
+
<p>An Ovto app must have <code>MainComponent</code> class, a subclass of <code>Ovto::Component</code>.</p>
|
294
294
|
<h2 id="render-method">'render' method</h2>
|
295
|
-
<p><code>render</code> is the only method you need to define in the <code>
|
295
|
+
<p><code>render</code> is the only method you need to define in the <code>MainComponent</code> class.
|
296
296
|
It must take the global app state as a keyword argument <code>state:</code>.</p>
|
297
|
-
<pre><code class="lang-rb"> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">
|
297
|
+
<pre><code class="lang-rb"> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MainComponent</span> < Ovto::Component</span>
|
298
298
|
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">render</span><span class="hljs-params">(<span class="hljs-symbol">state:</span>)</span></span>
|
299
299
|
o <span class="hljs-string">'div'</span> <span class="hljs-keyword">do</span>
|
300
300
|
o <span class="hljs-string">'h1'</span>, <span class="hljs-string">'Your todos'</span>
|
@@ -318,7 +318,7 @@ It must take the global app state as a keyword argument <code>state:</code>.</p>
|
|
318
318
|
<span class="hljs-keyword">end</span>
|
319
319
|
<span class="hljs-keyword">end</span>
|
320
320
|
|
321
|
-
<span class="hljs-comment">#=> $MoreThanOneNode {name: "MoreThanOneNode",
|
321
|
+
<span class="hljs-comment">#=> $MoreThanOneNode {name: "MoreThanOneNode", ...}</span>
|
322
322
|
</code></pre>
|
323
323
|
<h2 id="the-o-method">The 'o' method</h2>
|
324
324
|
<p><a name="the-o-method"></a></p>
|
@@ -387,8 +387,8 @@ You can get the input value with <code>e.target.value</code> here.</p>
|
|
387
387
|
<span class="hljs-keyword">end</span>
|
388
388
|
<span class="hljs-keyword">end</span>
|
389
389
|
|
390
|
-
<span class="hljs-comment"># Main
|
391
|
-
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">
|
390
|
+
<span class="hljs-comment"># Main component</span>
|
391
|
+
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MainComponent</span> < Ovto::Component</span>
|
392
392
|
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">render</span><span class="hljs-params">(<span class="hljs-symbol">state:</span>)</span></span>
|
393
393
|
o <span class="hljs-string">'div'</span> <span class="hljs-keyword">do</span>
|
394
394
|
o <span class="hljs-string">'h1'</span>, <span class="hljs-string">'Your todos'</span>
|
@@ -455,7 +455,7 @@ HTML could be described like this.</p>
|
|
455
455
|
<script>
|
456
456
|
var gitbook = gitbook || [];
|
457
457
|
gitbook.push(function() {
|
458
|
-
gitbook.page.hasChanged({"page":{"title":"Ovto::Component","level":"1.3.4","depth":2,"next":{"title":"Ovto.fetch","level":"1.3.5","depth":2,"path":"api/fetch.md","ref":"api/fetch.md","articles":[]},"previous":{"title":"Ovto::Actions","level":"1.3.3","depth":2,"path":"api/actions.md","ref":"api/actions.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"api/component.md","mtime":"2018-
|
458
|
+
gitbook.page.hasChanged({"page":{"title":"Ovto::Component","level":"1.3.4","depth":2,"next":{"title":"Ovto.fetch","level":"1.3.5","depth":2,"path":"api/fetch.md","ref":"api/fetch.md","articles":[]},"previous":{"title":"Ovto::Actions","level":"1.3.3","depth":2,"path":"api/actions.md","ref":"api/actions.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"api/component.md","mtime":"2018-12-23T09:45:52.000Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2018-12-24T12:23:40.758Z"},"basePath":"..","book":{"language":""}});
|
459
459
|
});
|
460
460
|
</script>
|
461
461
|
</div>
|
data/docs/api/fetch.html
ADDED
@@ -0,0 +1,392 @@
|
|
1
|
+
|
2
|
+
<!DOCTYPE HTML>
|
3
|
+
<html lang="" >
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
7
|
+
<title>Ovto.fetch · GitBook</title>
|
8
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
9
|
+
<meta name="description" content="">
|
10
|
+
<meta name="generator" content="GitBook 3.2.2">
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../gitbook/style.css">
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
<link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
<meta name="HandheldFriendly" content="true"/>
|
53
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
54
|
+
<meta name="apple-mobile-web-app-capable" content="yes">
|
55
|
+
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
56
|
+
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
|
57
|
+
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
<link rel="prev" href="component.html" />
|
62
|
+
|
63
|
+
|
64
|
+
</head>
|
65
|
+
<body>
|
66
|
+
|
67
|
+
<div class="book">
|
68
|
+
<div class="book-summary">
|
69
|
+
|
70
|
+
|
71
|
+
<div id="book-search-input" role="search">
|
72
|
+
<input type="text" placeholder="Type to search" />
|
73
|
+
</div>
|
74
|
+
|
75
|
+
|
76
|
+
<nav role="navigation">
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
<ul class="summary">
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
<li class="chapter " data-level="1.1" data-path="../">
|
91
|
+
|
92
|
+
<a href="../">
|
93
|
+
|
94
|
+
|
95
|
+
Introduction
|
96
|
+
|
97
|
+
</a>
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
</li>
|
102
|
+
|
103
|
+
<li class="chapter " data-level="1.2" data-path="../guides/tutorial.html">
|
104
|
+
|
105
|
+
<a href="../guides/tutorial.html">
|
106
|
+
|
107
|
+
|
108
|
+
Getting Started
|
109
|
+
|
110
|
+
</a>
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
</li>
|
115
|
+
|
116
|
+
<li class="chapter " data-level="1.3" >
|
117
|
+
|
118
|
+
<span>
|
119
|
+
|
120
|
+
|
121
|
+
API
|
122
|
+
|
123
|
+
</span>
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
<ul class="articles">
|
128
|
+
|
129
|
+
|
130
|
+
<li class="chapter " data-level="1.3.1" data-path="app.html">
|
131
|
+
|
132
|
+
<a href="app.html">
|
133
|
+
|
134
|
+
|
135
|
+
Ovto::App
|
136
|
+
|
137
|
+
</a>
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
</li>
|
142
|
+
|
143
|
+
<li class="chapter " data-level="1.3.2" data-path="state.html">
|
144
|
+
|
145
|
+
<a href="state.html">
|
146
|
+
|
147
|
+
|
148
|
+
Ovto::State
|
149
|
+
|
150
|
+
</a>
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
</li>
|
155
|
+
|
156
|
+
<li class="chapter " data-level="1.3.3" data-path="actions.html">
|
157
|
+
|
158
|
+
<a href="actions.html">
|
159
|
+
|
160
|
+
|
161
|
+
Ovto::Actions
|
162
|
+
|
163
|
+
</a>
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
</li>
|
168
|
+
|
169
|
+
<li class="chapter " data-level="1.3.4" data-path="component.html">
|
170
|
+
|
171
|
+
<a href="component.html">
|
172
|
+
|
173
|
+
|
174
|
+
Ovto::Component
|
175
|
+
|
176
|
+
</a>
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
</li>
|
181
|
+
|
182
|
+
<li class="chapter active" data-level="1.3.5" data-path="fetch.html">
|
183
|
+
|
184
|
+
<a href="fetch.html">
|
185
|
+
|
186
|
+
|
187
|
+
Ovto.fetch
|
188
|
+
|
189
|
+
</a>
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
</li>
|
194
|
+
|
195
|
+
|
196
|
+
</ul>
|
197
|
+
|
198
|
+
</li>
|
199
|
+
|
200
|
+
<li class="chapter " data-level="1.4" >
|
201
|
+
|
202
|
+
<span>
|
203
|
+
|
204
|
+
|
205
|
+
Guides
|
206
|
+
|
207
|
+
</span>
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
<ul class="articles">
|
212
|
+
|
213
|
+
|
214
|
+
<li class="chapter " data-level="1.4.1" data-path="../guides/debugging.html">
|
215
|
+
|
216
|
+
<a href="../guides/debugging.html">
|
217
|
+
|
218
|
+
|
219
|
+
Debugging
|
220
|
+
|
221
|
+
</a>
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
</li>
|
226
|
+
|
227
|
+
<li class="chapter " data-level="1.4.2" data-path="../guides/development.html">
|
228
|
+
|
229
|
+
<a href="../guides/development.html">
|
230
|
+
|
231
|
+
|
232
|
+
Development
|
233
|
+
|
234
|
+
</a>
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
</li>
|
239
|
+
|
240
|
+
|
241
|
+
</ul>
|
242
|
+
|
243
|
+
</li>
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
<li class="divider"></li>
|
249
|
+
|
250
|
+
<li>
|
251
|
+
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
|
252
|
+
Published with GitBook
|
253
|
+
</a>
|
254
|
+
</li>
|
255
|
+
</ul>
|
256
|
+
|
257
|
+
|
258
|
+
</nav>
|
259
|
+
|
260
|
+
|
261
|
+
</div>
|
262
|
+
|
263
|
+
<div class="book-body">
|
264
|
+
|
265
|
+
<div class="body-inner">
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
<div class="book-header" role="navigation">
|
270
|
+
|
271
|
+
|
272
|
+
<!-- Title -->
|
273
|
+
<h1>
|
274
|
+
<i class="fa fa-circle-o-notch fa-spin"></i>
|
275
|
+
<a href=".." >Ovto.fetch</a>
|
276
|
+
</h1>
|
277
|
+
</div>
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
<div class="page-wrapper" tabindex="-1" role="main">
|
283
|
+
<div class="page-inner">
|
284
|
+
|
285
|
+
<div id="book-search-results">
|
286
|
+
<div class="search-noresults">
|
287
|
+
|
288
|
+
<section class="normal markdown-section">
|
289
|
+
|
290
|
+
<h1 id="ovtofetch">Ovto.fetch</h1>
|
291
|
+
<p>Ovto provides wrapper of <a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch" target="_blank">Fetch API</a>, for convenience of calling typical server-side APIs (eg. those generated by <code>rails scaffold</code> command.)</p>
|
292
|
+
<p><code>Ovto.fetch</code> returns Opal's Promise object that calls the API with the specified parameters.</p>
|
293
|
+
<h2 id="examples">Examples</h2>
|
294
|
+
<p>GET</p>
|
295
|
+
<pre><code class="lang-rb">Ovto.fetch(<span class="hljs-string">'/api/tasks'</span>){|json_data|
|
296
|
+
p json_data
|
297
|
+
}.fail{|e| <span class="hljs-comment"># Network error, 404 Not Found, JSON parse error, etc.</span>
|
298
|
+
p e
|
299
|
+
}
|
300
|
+
</code></pre>
|
301
|
+
<p>POST</p>
|
302
|
+
<pre><code class="lang-rb">Ovto.fetch(<span class="hljs-string">'/api/new_task'</span>, <span class="hljs-string">'POST'</span>, {<span class="hljs-symbol">title:</span> <span class="hljs-string">"do something"</span>}){|json_data|
|
303
|
+
p json_data
|
304
|
+
}.fail{|e| <span class="hljs-comment"># Network error, 404 Not Found, JSON parse error, etc.</span>
|
305
|
+
p e
|
306
|
+
}
|
307
|
+
</code></pre>
|
308
|
+
<p>PUT</p>
|
309
|
+
<pre><code class="lang-rb">Ovto.fetch(<span class="hljs-string">'/api/tasks/1'</span>, <span class="hljs-string">'PUT'</span>, {<span class="hljs-symbol">title:</span> <span class="hljs-string">"do something"</span>}){|json_data|
|
310
|
+
p json_data
|
311
|
+
}.fail{|e| <span class="hljs-comment"># Network error, 404 Not Found, JSON parse error, etc.</span>
|
312
|
+
p e
|
313
|
+
}
|
314
|
+
</code></pre>
|
315
|
+
<h2 id="csrf-tokens">CSRF tokens</h2>
|
316
|
+
<p>You don't need to care about CSRF tokens if the server is a Rails app because <code>Ovto.fetch</code> automatically send <code>X-CSRF-Token</code> header if the page contains a meta tag like <code><meta name='csrf-token' content='....' /></code>.</p>
|
317
|
+
|
318
|
+
|
319
|
+
</section>
|
320
|
+
|
321
|
+
</div>
|
322
|
+
<div class="search-results">
|
323
|
+
<div class="has-results">
|
324
|
+
|
325
|
+
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
326
|
+
<ul class="search-results-list"></ul>
|
327
|
+
|
328
|
+
</div>
|
329
|
+
<div class="no-results">
|
330
|
+
|
331
|
+
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
332
|
+
|
333
|
+
</div>
|
334
|
+
</div>
|
335
|
+
</div>
|
336
|
+
|
337
|
+
</div>
|
338
|
+
</div>
|
339
|
+
|
340
|
+
</div>
|
341
|
+
|
342
|
+
|
343
|
+
|
344
|
+
<a href="component.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page: Ovto::Component">
|
345
|
+
<i class="fa fa-angle-left"></i>
|
346
|
+
</a>
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
</div>
|
352
|
+
|
353
|
+
<script>
|
354
|
+
var gitbook = gitbook || [];
|
355
|
+
gitbook.push(function() {
|
356
|
+
gitbook.page.hasChanged({"page":{"title":"Ovto.fetch","level":"1.3.5","depth":2,"next":{"title":"Guides","level":"1.4","depth":1,"ref":"","articles":[{"title":"Debugging","level":"1.4.1","depth":2,"path":"guides/debugging.md","ref":"guides/debugging.md","articles":[]},{"title":"Development","level":"1.4.2","depth":2,"path":"guides/development.md","ref":"guides/development.md","articles":[]}]},"previous":{"title":"Ovto::Component","level":"1.3.4","depth":2,"path":"api/component.md","ref":"api/component.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"api/fetch.md","mtime":"2018-08-18T07:44:18.000Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2018-12-24T12:23:40.758Z"},"basePath":"..","book":{"language":""}});
|
357
|
+
});
|
358
|
+
</script>
|
359
|
+
</div>
|
360
|
+
|
361
|
+
|
362
|
+
<script src="../gitbook/gitbook.js"></script>
|
363
|
+
<script src="../gitbook/theme.js"></script>
|
364
|
+
|
365
|
+
|
366
|
+
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
|
367
|
+
|
368
|
+
|
369
|
+
|
370
|
+
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
|
371
|
+
|
372
|
+
|
373
|
+
|
374
|
+
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
375
|
+
|
376
|
+
|
377
|
+
|
378
|
+
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
379
|
+
|
380
|
+
|
381
|
+
|
382
|
+
<script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
|
383
|
+
|
384
|
+
|
385
|
+
|
386
|
+
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
387
|
+
|
388
|
+
|
389
|
+
|
390
|
+
</body>
|
391
|
+
</html>
|
392
|
+
|