Skip to content
This repository was archived by the owner on Oct 19, 2018. It is now read-only.

Commit 4bdb674

Browse files
committed
Site updated to 19460a4
1 parent 7d64cbd commit 4bdb674

File tree

5 files changed

+59
-81
lines changed

5 files changed

+59
-81
lines changed

docs/components/docs/index.html

Lines changed: 45 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -456,10 +456,10 @@ <h2 class="h5 project-tagline center-text">
456456
<a href="#what-components-should-have-state">What Components Should Have State?</a>
457457
</li>
458458
<li class="navtoc-item">
459-
<a href="#what-should-go-in-state">What <em>Should</em> Go in State?</a>
459+
<a href="#what-should-go-in-state">What Should Go in State?</a>
460460
</li>
461461
<li class="navtoc-item">
462-
<a href="#what-shouldn-t-go-in-state">What <em>Shouldn't</em> Go in State?</a>
462+
<a href="#what-shouldn-t-go-in-state">What Shouldn't Go in State?</a>
463463
</li>
464464
</ul>
465465
</li>
@@ -1012,22 +1012,18 @@ <h3 id="using-state">Using State</h3>
10121012

10131013
<h4 id="a-simple-example">A Simple Example</h4>
10141014

1015-
<div class="codemirror-live-edit"
1016-
data-heading="A simple Component rendering state"
1017-
data-rows=12
1018-
data-top-level-component="LikeButton">
1019-
<pre>
1020-
class LikeButton < Hyperloop::Component
1015+
<p>```ruby runable
1016+
class LikeButton &lt; Hyperloop::Component</p>
10211017

1022-
render(DIV) do
1018+
<p>render(DIV) do
10231019
P do
1024-
"You #{state.liked ? 'like' : 'haven\'t liked'} this. Click to toggle."
1020+
&quot;You #{state.liked ? &#39;like&#39; : &#39;haven\&#39;t liked&#39;} this. Click to toggle.&quot;
10251021
end.on(:click) do
10261022
mutate.liked !state.liked
10271023
end
10281024
end
10291025
end
1030-
</pre></div>
1026+
```</p>
10311027

10321028
<h3 id="components-are-just-state-machines">Components are Just State Machines</h3>
10331029

@@ -1047,14 +1043,14 @@ <h3 id="what-components-should-have-state">What Components Should Have State?</h
10471043

10481044
<p>A common pattern is to create several stateless components that just render data, and have a stateful component above them in the hierarchy that passes its state to its children via <code>params</code>. The stateful component encapsulates all of the interaction logic, while the stateless components take care of rendering data in a declarative way.</p>
10491045

1050-
<h3 id="what-should-go-in-state">What <em>Should</em> Go in State?</h3>
1046+
<h3 id="what-should-go-in-state">What Should Go in State?</h3>
10511047

10521048
<p><strong>State should contain data that a component&#39;s event handlers, timers, or http requests may change and trigger a UI update.</strong></p>
10531049

10541050
<p>When building a stateful component, think about the minimal possible representation of its state, and only store those properties in <code>state</code>. Add to your class methods to compute higher level values from your state variables. Avoid adding redundant or computed values as state variables as
10551051
these values must then be kept in sync whenever state changes.</p>
10561052

1057-
<h3 id="what-shouldnt-go-in-state">What <em>Shouldn&#39;t</em> Go in State?</h3>
1053+
<h3 id="what-shouldnt-go-in-state">What Shouldn&#39;t Go in State?</h3>
10581054

10591055
<p><code>state</code> should only contain the minimal amount of data needed to represent your UI&#39;s state. As such, it should not contain:</p>
10601056

@@ -1196,7 +1192,7 @@ <h3 id="data-flow">Data Flow</h3>
11961192

11971193
<h3 id="stores">Stores</h3>
11981194

1199-
<p>Managing state between components is best done using Stores as many Components can access one store. This saves passing data btween Components. Please see the <a href="/docs/stores/docs">Store documentation</a> for details.</p>
1195+
<p>Managing state between components is best done using Stores as many Components can access one store. This saves passing data btween Components. Please see the <a href="/docs/stores/overview">Store documentation</a> for details.</p>
12001196

12011197
<h3 id="reusable-components">Reusable Components</h3>
12021198

@@ -1260,44 +1256,40 @@ <h3 id="mixins-and-inheritance">Mixins and Inheritance</h3>
12601256
</code></pre>
12611257
<p>One common use case is a component wanting to update itself on a time interval. It&#39;s easy to use the kernel method <code>every</code>, but it&#39;s important to cancel your interval when you don&#39;t need it anymore to save memory. React provides <a href="/docs/working-with-the-browser.html#component-lifecycle">lifecycle methods</a> that let you know when a component is about to be created or destroyed. Let&#39;s create a simple mixin that uses these methods to provide a React friendly <code>every</code> function that will automatically get cleaned up when your component is destroyed.</p>
12621258

1263-
<div class="codemirror-live-edit"
1264-
data-heading="Using state"
1265-
data-rows=33
1266-
data-top-level-component="TickTock">
1267-
<pre>
1268-
module ReactInterval
1259+
<p>```ruby runable
1260+
module ReactInterval</p>
12691261

1270-
def self.included(base)
1262+
<p>def self.included(base)
12711263
base.before_mount do
12721264
@intervals = []
1273-
end
1274-
1275-
base.before_unmount do
1276-
@intervals.each(&:stop)
1277-
end
1278-
end
1265+
end</p>
1266+
<pre class="highlight plaintext"><code>base.before_unmount do
1267+
@intervals.each(&amp;:stop)
1268+
end
1269+
</code></pre>
1270+
<p>end</p>
12791271

1280-
def every(seconds, &block)
1281-
Kernel.every(seconds, &block).tap { |i| @intervals << i }
1272+
<p>def every(seconds, &amp;block)
1273+
Kernel.every(seconds, &amp;block).tap { |i| @intervals &lt;&lt; i }
12821274
end
1283-
end
1275+
end</p>
12841276

1285-
class TickTock < Hyperloop::Component
1286-
include ReactInterval
1277+
<p>class TickTock &lt; Hyperloop::Component
1278+
include ReactInterval</p>
12871279

1288-
before_mount do
1280+
<p>before_mount do
12891281
state.seconds! 0
1290-
end
1282+
end</p>
12911283

1292-
after_mount do
1284+
<p>after_mount do
12931285
every(1) { mutate.seconds state.seconds+1}
1294-
end
1286+
end</p>
12951287

1296-
render(DIV) do
1297-
"Hyperloop has been running for #{state.seconds} seconds".para
1288+
<p>render(DIV) do
1289+
&quot;Hyperloop has been running for #{state.seconds} seconds&quot;.para
12981290
end
12991291
end
1300-
</pre></div>
1292+
```</p>
13011293

13021294
<p>Notice that TickTock effectively has two before_mount callbacks, one that is called to initialize the <code>@intervals</code> array and another to initialize <code>state.seconds</code></p>
13031295

@@ -1432,31 +1424,27 @@ <h4 id="the-children-method">The children method</h4>
14321424

14331425
<p>The instance method <code>children</code> returns an enumerable that is used to access the unrendered children of a component.</p>
14341426

1435-
<div class="codemirror-live-edit"
1436-
data-heading="The children method"
1437-
data-rows=20
1438-
data-top-level-component="Indenter">
1439-
<pre>
1440-
class IndentEachLine < Hyperloop::Component
1441-
param by: 20, type: Integer
1427+
<p>```ruby runable
1428+
class IndentEachLine &lt; Hyperloop::Component
1429+
param by: 20, type: Integer</p>
14421430

1443-
render(DIV) do
1444-
children.each_with_index do |child, i|
1445-
child.render(style: {"margin-left" => params.by*i})
1431+
<p>render(DIV) do
1432+
children.each<em>with</em>index do |child, i|
1433+
child.render(style: {&quot;margin-left&quot; =&gt; params.by*i})
14461434
end
14471435
end
1448-
end
1436+
end</p>
14491437

1450-
class Indenter < Hyperloop::Component
1438+
<p>class Indenter &lt; Hyperloop::Component
14511439
render(DIV) do
14521440
IndentEachLine(by: 100) do
1453-
DIV {"Line 1"}
1454-
DIV {"Line 2"}
1455-
DIV {"Line 3"}
1441+
DIV {&quot;Line 1&quot;}
1442+
DIV {&quot;Line 2&quot;}
1443+
DIV {&quot;Line 3&quot;}
14561444
end
14571445
end
14581446
end
1459-
</pre></div>
1447+
```</p>
14601448

14611449
<h3 id="lifecycle-methods">Lifecycle Methods</h3>
14621450

@@ -1934,10 +1922,8 @@ <h4 id="including-react-source">Including React Source</h4>
19341922
<p>If you are in the business of importing components with a tool like Webpack, then you will need to let Webpack (or whatever dependency manager you are using) take care of including the React source code. Just make sure that you are <em>not</em> including it on the ruby side of things. Hyperloop is currently tested with React versions 13, 14, and 15, so its not sensitive to the version you use.</p>
19351923

19361924
<p>However it gets a little tricky if you are using the react-rails gem. Each version of this gem depends on a specific version of React, and so you will need to manually declare this dependency in your Javascript dependency manager. Consult this <a href="https://github.com/reactjs/react-rails/blob/master/VERSIONS.md">table</a> to determine which version of React you need. For example assuming you are using <code>npm</code> to install modules and you are using version 1.7.2 of react-rails you would say something like this:</p>
1937-
<pre class="highlight shell"><code>npm install react@15.6.2 react-dom@15.6.2 --save
1925+
<pre class="highlight shell"><code>npm install react@15.0.2 react-dom@15.0.2 --save
19381926
</code></pre>
1939-
<p>See <a href="/tutorials/hyperlooprails/webpack/">{ NPM and Webpack Tutorial }</a> or <a href="/tutorials/hyperlooprails/hyperloop-rails-webpackergem-helloworld/">{ Webpacker GEM Tutorial }</a> for more information.</p>
1940-
19411927
<h4 id="using-webpack">Using Webpack</h4>
19421928

19431929
<p>Just a word on Webpack: If you a Ruby developer who is new to using Javascript libraries then we recommend using Webpack to manage javascript component dependencies. Webpack is essentially bundler for Javascript. Please see our Tutorials section for more information.</p>
@@ -1996,7 +1982,7 @@ <h4 id="opal-under-the-covers">Opal under the covers</h4>
19961982
<p>Hyperloop Components are a DSL wrapper of React which uses Opal to compile Ruby code to ES5 native JavaScript. If you have not used Opal before then you should at a minimum read the excellent guides as they will teach you enough Opal to get you started with Hyperloop.</p>
19971983

19981984
<ul>
1999-
<li><a href="http://opalrb.org/">Opal</a></li>
1985+
<li><a href="http://opalrb.com/">Opal</a></li>
20001986
<li><a href="http://opalrb.org/docs/guides/v0.9.2/index.html">Opal Guides</a></li>
20011987
<li><a href="https://www.youtube.com/watch?v=vhIrrlcWphU">To see the full power of Opal in action watch this video</a></li>
20021988
</ul>

feed.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<link rel="alternate" href="http://blog.url.com/blog/2017/02/28/spring-2017-comps-release/"/>
1515
<id>http://blog.url.com/blog/2017/02/28/spring-2017-comps-release/</id>
1616
<published>2017-02-28T00:00:00+00:00</published>
17-
<updated>2018-01-29T17:03:06+00:00</updated>
17+
<updated>2018-06-01T08:14:59+01:00</updated>
1818
<author>
1919
<name>Article Author</name>
2020
</author>
@@ -171,7 +171,7 @@
171171
<link rel="alternate" href="http://blog.url.com/blog/2017/01/28/editing-flux-loop-verses-decoupling/"/>
172172
<id>http://blog.url.com/blog/2017/01/28/editing-flux-loop-verses-decoupling/</id>
173173
<published>2017-01-28T00:00:00+00:00</published>
174-
<updated>2018-01-29T17:03:06+00:00</updated>
174+
<updated>2018-06-01T08:14:59+01:00</updated>
175175
<author>
176176
<name>Article Author</name>
177177
</author>
@@ -323,7 +323,7 @@ Yes. Note that Operations return promises, so asynchronous operation is assumed
323323
<link rel="alternate" href="http://blog.url.com/blog/2017/01/17/comparing-redux-with-hyperloop/"/>
324324
<id>http://blog.url.com/blog/2017/01/17/comparing-redux-with-hyperloop/</id>
325325
<published>2017-01-17T00:00:00+00:00</published>
326-
<updated>2018-01-29T17:03:06+00:00</updated>
326+
<updated>2018-06-01T08:14:59+01:00</updated>
327327
<author>
328328
<name>Article Author</name>
329329
</author>
@@ -655,7 +655,7 @@ return (
655655
<link rel="alternate" href="http://blog.url.com/blog/2016/09/08/Hyperloop-is-born/"/>
656656
<id>http://blog.url.com/blog/2016/09/08/Hyperloop-is-born/</id>
657657
<published>2016-09-08T06:50:00+01:00</published>
658-
<updated>2018-01-29T17:03:06+00:00</updated>
658+
<updated>2018-06-01T08:14:59+01:00</updated>
659659
<author>
660660
<name>Article Author</name>
661661
</author>
@@ -710,7 +710,7 @@ return (
710710
<link rel="alternate" href="http://blog.url.com/blog/2016/06/29/reactrb-v0-8-5/"/>
711711
<id>http://blog.url.com/blog/2016/06/29/reactrb-v0-8-5/</id>
712712
<published>2016-06-29T01:00:00+01:00</published>
713-
<updated>2018-01-29T17:03:06+00:00</updated>
713+
<updated>2018-06-01T08:14:59+01:00</updated>
714714
<author>
715715
<name>Article Author</name>
716716
</author>
@@ -812,7 +812,7 @@ return (
812812
<link rel="alternate" href="http://blog.url.com/blog/2016/01/26/getting-started-with-reactrb-and-rails/"/>
813813
<id>http://blog.url.com/blog/2016/01/26/getting-started-with-reactrb-and-rails/</id>
814814
<published>2016-01-26T16:29:00+00:00</published>
815-
<updated>2018-01-29T17:03:06+00:00</updated>
815+
<updated>2018-06-01T08:14:59+01:00</updated>
816816
<author>
817817
<name>Article Author</name>
818818
</author>

search/lunr-index.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

tutorials/hyperlooprails/hyperloop-rails-webpackergem-helloworld/index.html

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ <h4 id="step-1-1-installing-and-setting-up-the-webpacker-gem">Step 1.1 - Install
492492
<pre class="highlight ruby"><code><span class="n">bundle</span> <span class="n">update</span>
493493
</code></pre>
494494
<p>Run the webpacker install generator:</p>
495-
<pre class="highlight plaintext"><code>bundle exec rails webpacker:install
495+
<pre class="highlight plaintext"><code>bin/rails webpacker:install
496496
</code></pre>
497497
<h4 id="step-1-2-adding-libraries-into-webpack">Step 1.2 - Adding libraries into Webpack:</h4>
498498

@@ -502,10 +502,10 @@ <h4 id="step-1-2-adding-libraries-into-webpack">Step 1.2 - Adding libraries into
502502
React, React-dom, Bootstrap and Bootswatch theme.</p>
503503

504504
<p>Run these commands:</p>
505-
<pre class="highlight plaintext"><code>yarn add react@15.6.2
506-
yarn add react-dom@15.6.2
505+
<pre class="highlight plaintext"><code>yarn add react
506+
yarn add react-dom
507507
yarn add bootstrap react-bootstrap
508-
yarn add bootswatch@3.3.7
508+
yarn add bootswatch
509509
</code></pre>
510510
<h4 id="step-1-3-requiring-the-libraires">Step 1.3 - Requiring the libraires</h4>
511511

@@ -523,8 +523,8 @@ <h4 id="step-1-4-letting-webpack-know-react-and-reactdom-are-external">Step 1.4
523523

524524
<p>React and ReactDOM are being brought in by Hyperloop, so we need to let Webpack know that these libraries are external so we do not end up with more than one copy of React running. Note that you will also need to do this for your production environment.</p>
525525

526-
<p>In the <code>module.export</code> block, add the following to <code>shared.js</code>:</p>
527-
<pre class="highlight javascript"><code><span class="c1">//config/webpack/shared.js</span>
526+
<p>In the <code>module.export</code> block, add the following to <code>development.js</code>:</p>
527+
<pre class="highlight javascript"><code><span class="c1">//config/webpack/development.js</span>
528528

529529
<span class="nl">externals</span><span class="p">:</span> <span class="p">{</span>
530530
<span class="s2">"react"</span><span class="p">:</span> <span class="s2">"React"</span><span class="p">,</span>
@@ -562,23 +562,15 @@ <h4 id="step-1-7-adding-pack-files-to-the-asset-pipeline">Step 1.7 - Adding pack
562562

563563
<span class="no">Hyperloop</span><span class="p">.</span><span class="nf">configuration</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
564564
<span class="n">config</span><span class="p">.</span><span class="nf">transport</span> <span class="o">=</span> <span class="ss">:simple_poller</span>
565-
566-
<span class="c1"># If your Webpacker version DO NOT generate Manifest files</span>
567565
<span class="n">config</span><span class="p">.</span><span class="nf">import</span> <span class="s1">'client_and_server'</span>
568566
<span class="n">config</span><span class="p">.</span><span class="nf">import</span> <span class="s1">'client_only'</span><span class="p">,</span> <span class="ss">client_only: </span><span class="kp">true</span>
569-
570-
<span class="c1"># If your Webpacker version DOES generate Manifest files</span>
571-
<span class="c1"># config.import Webpacker.manifest.lookup("client_and_server.js").split("/").last</span>
572-
<span class="c1"># config.import Webpacker.manifest.lookup("client_only.js").split("/").last</span>
573567
<span class="k">end</span>
574568
</code></pre>
575569
<p><i class="flaticon-signs"></i> In Rails production mode it would be necessary to include the pack files in your application main layout:</p>
576570
<pre class="highlight erb"><code>#app/views/layouts/application.tml.erb
577571

578572
<span class="cp">&lt;%=</span> <span class="n">javascript_pack_tag</span> <span class="s1">'client_and_server'</span> <span class="cp">%&gt;</span>
579573
</code></pre>
580-
<p>And <a href="/docs/advancedconfiguration/#auto_config">{ set Hyperloop in AUTO-CONFIG MODE = OFF }</a> in order to choose manually which libraries will be imported.</p>
581-
582574
<h4 id="step-1-8-adding-css-pack-files-to-the-asset-pipeline">Step 1.8 - Adding CSS pack files to the asset pipeline</h4>
583575

584576
<p>Add this line:</p>

tutorials/hyperlooprails/todo-tutorial/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ <h2 align="center">The Complete Isomorphic Ruby Framework</h2>
446446

447447
</div>
448448

449-
<h2 id="hyperloop-todomvc-tutorial"><i class="flaticon-professor-teaching"></i><span class="bigfirstletter">H</span>yperloop TodoMVC Tutorial</h2>
449+
<h2 id="hyperloop-todomvc-tutorial">Hyperloop TodoMVC Tutorial</h2>
450450

451451
<p><img src="http://ruby-hyperloop.org/images/tutorials/Hyperloop-Railstodomvc.gif" alt="Hyperloop railstodomvc" /></p>
452452

0 commit comments

Comments
 (0)