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

Commit 9850720

Browse files
Site updated to 2d36f27
1 parent 0996d4a commit 9850720

File tree

6 files changed

+262
-228
lines changed

6 files changed

+262
-228
lines changed

docs/components/docs/index.html

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

10101010
<h4 id="a-simple-example">A Simple Example</h4>
10111011

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

1015-
<p>render(DIV) do
1019+
render(DIV) do
10161020
P do
1017-
&quot;You #{state.liked ? &#39;like&#39; : &#39;haven\&#39;t liked&#39;} this. Click to toggle.&quot;
1021+
"You #{state.liked ? 'like' : 'haven\'t liked'} this. Click to toggle."
10181022
end.on(:click) do
10191023
mutate.liked !state.liked
10201024
end
10211025
end
10221026
end
1023-
```</p>
1027+
</pre></div>
10241028

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

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

10411045
<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>
10421046

1043-
<h3 id="what-should-go-in-state">What Should Go in State?</h3>
1047+
<h3 id="what-should-go-in-state">What <em>Should</em> Go in State?</h3>
10441048

10451049
<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>
10461050

10471051
<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
10481052
these values must then be kept in sync whenever state changes.</p>
10491053

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

10521056
<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>
10531057

@@ -1189,7 +1193,7 @@ <h3 id="data-flow">Data Flow</h3>
11891193

11901194
<h3 id="stores">Stores</h3>
11911195

1192-
<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>
1196+
<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>
11931197

11941198
<h3 id="reusable-components">Reusable Components</h3>
11951199

@@ -1253,40 +1257,44 @@ <h3 id="mixins-and-inheritance">Mixins and Inheritance</h3>
12531257
</code></pre>
12541258
<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>
12551259

1256-
<p>```ruby runable
1257-
module ReactInterval</p>
1260+
<div class="codemirror-live-edit"
1261+
data-heading="Using state"
1262+
data-rows=33
1263+
data-top-level-component="TickTock">
1264+
<pre>
1265+
module ReactInterval
12581266

1259-
<p>def self.included(base)
1267+
def self.included(base)
12601268
base.before_mount do
12611269
@intervals = []
1262-
end</p>
1263-
<pre class="highlight plaintext"><code>base.before_unmount do
1264-
@intervals.each(&amp;:stop)
1265-
end
1266-
</code></pre>
1267-
<p>end</p>
1270+
end
12681271

1269-
<p>def every(seconds, &amp;block)
1270-
Kernel.every(seconds, &amp;block).tap { |i| @intervals &lt;&lt; i }
1272+
base.before_unmount do
1273+
@intervals.each(&:stop)
1274+
end
1275+
end
1276+
1277+
def every(seconds, &block)
1278+
Kernel.every(seconds, &block).tap { |i| @intervals << i }
12711279
end
1272-
end</p>
1280+
end
12731281

1274-
<p>class TickTock &lt; Hyperloop::Component
1275-
include ReactInterval</p>
1282+
class TickTock < Hyperloop::Component
1283+
include ReactInterval
12761284

1277-
<p>before_mount do
1285+
before_mount do
12781286
state.seconds! 0
1279-
end</p>
1287+
end
12801288

1281-
<p>after_mount do
1289+
after_mount do
12821290
every(1) { mutate.seconds state.seconds+1}
1283-
end</p>
1291+
end
12841292

1285-
<p>render(DIV) do
1286-
&quot;Hyperloop has been running for #{state.seconds} seconds&quot;.para
1293+
render(DIV) do
1294+
"Hyperloop has been running for #{state.seconds} seconds".para
12871295
end
12881296
end
1289-
```</p>
1297+
</pre></div>
12901298

12911299
<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>
12921300

@@ -1421,27 +1429,31 @@ <h4 id="the-children-method">The children method</h4>
14211429

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

1424-
<p>```ruby runable
1425-
class IndentEachLine &lt; Hyperloop::Component
1426-
param by: 20, type: Integer</p>
1432+
<div class="codemirror-live-edit"
1433+
data-heading="The children method"
1434+
data-rows=20
1435+
data-top-level-component="Indenter">
1436+
<pre>
1437+
class IndentEachLine < Hyperloop::Component
1438+
param by: 20, type: Integer
14271439

1428-
<p>render(DIV) do
1429-
children.each<em>with</em>index do |child, i|
1430-
child.render(style: {&quot;margin-left&quot; =&gt; params.by*i})
1440+
render(DIV) do
1441+
children.each_with_index do |child, i|
1442+
child.render(style: {"margin-left" => params.by*i})
14311443
end
14321444
end
1433-
end</p>
1445+
end
14341446

1435-
<p>class Indenter &lt; Hyperloop::Component
1447+
class Indenter < Hyperloop::Component
14361448
render(DIV) do
14371449
IndentEachLine(by: 100) do
1438-
DIV {&quot;Line 1&quot;}
1439-
DIV {&quot;Line 2&quot;}
1440-
DIV {&quot;Line 3&quot;}
1450+
DIV {"Line 1"}
1451+
DIV {"Line 2"}
1452+
DIV {"Line 3"}
14411453
end
14421454
end
14431455
end
1444-
```</p>
1456+
</pre></div>
14451457

14461458
<h3 id="lifecycle-methods">Lifecycle Methods</h3>
14471459

@@ -1919,8 +1931,10 @@ <h4 id="including-react-source">Including React Source</h4>
19191931
<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>
19201932

19211933
<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>
1922-
<pre class="highlight shell"><code>npm install react@15.0.2 react-dom@15.0.2 --save
1934+
<pre class="highlight shell"><code>npm install react@15.6.2 react-dom@15.6.2 --save
19231935
</code></pre>
1936+
<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>
1937+
19241938
<h4 id="using-webpack">Using Webpack</h4>
19251939

19261940
<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>
@@ -1979,7 +1993,7 @@ <h4 id="opal-under-the-covers">Opal under the covers</h4>
19791993
<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>
19801994

19811995
<ul>
1982-
<li><a href="http://opalrb.com/">Opal</a></li>
1996+
<li><a href="http://opalrb.org/">Opal</a></li>
19831997
<li><a href="http://opalrb.org/docs/guides/v0.9.2/index.html">Opal Guides</a></li>
19841998
<li><a href="https://www.youtube.com/watch?v=vhIrrlcWphU">To see the full power of Opal in action watch this video</a></li>
19851999
</ul>

docs/models/docs/index.html

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,9 @@ <h2 class="h5 project-tagline center-text">
405405
<li class="navtoc-item">
406406
<a href="#rails-5-1-x">Rails 5.1.x</a>
407407
</li>
408+
<li class="navtoc-item">
409+
<a href="#explicit-scope-access">Explicit Scope Access</a>
410+
</li>
408411
</ul>
409412
</li>
410413
<li class="navtoc-item">
@@ -624,7 +627,7 @@ <h2 id="isomorphic-models">Isomorphic Models</h2>
624627

625628
<h3 id="rails-5-1-x">Rails 5.1.x</h3>
626629

627-
<p>Upto Rails 4.2, all models inherited from <code>ActiveRecord::Base</code>. But starting from Rails 5, all models will inherit from <code>ApplicationRecord</code>.</p>
630+
<p>Up until Rails 4.2, all models inherited from <code>ActiveRecord::Base</code>. But starting from Rails 5, all models will inherit from <code>ApplicationRecord</code>.</p>
628631

629632
<p>To accommodate this change, the following file has been automatically added to models in Rails 5 applications.</p>
630633
<pre class="highlight ruby"><code><span class="c1"># app/models/application_record.rb</span>
@@ -634,6 +637,15 @@ <h3 id="rails-5-1-x">Rails 5.1.x</h3>
634637
</code></pre>
635638
<p>For Hyperloop to see this change, this file needs to be moved (or copied if you have some server-side models) to the <code>apps/hyperloop</code> folder.</p>
636639

640+
<h3 id="explicit-scope-access">Explicit Scope Access</h3>
641+
642+
<p>In order to prevent unauthorized access to information like scope counts, lists of record ids, etc, Hyperloop now (see issue <a href="https://github.com/ruby-hyperloop/hyper-mesh/issues/43">https://github.com/ruby-hyperloop/hyper-mesh/issues/43</a>) requires you explicitly allow scopes to be viewed on the client, otherwise you will get an AccessViolation.</p>
643+
644+
<p>To globally allow access to all scopes add this to the ApplicationRecord class</p>
645+
<pre class="highlight ruby"><code><span class="k">class</span> <span class="nc">ApplicationRecord</span> <span class="o">&lt;</span> <span class="no">ActiveRecord</span><span class="o">::</span><span class="no">Base</span>
646+
<span class="n">regulate_scope</span> <span class="ss">:all</span>
647+
<span class="k">end</span>
648+
</code></pre>
637649
<h2 id="activerecord-api">ActiveRecord API</h2>
638650

639651
<p>Hyperloop uses a subset of the standard ActiveRecord API to give your Isomorphic Components, Operations and Stores access to your server side Models. As much as possible Hyperloop follows the syntax and semantics of ActiveRecord. </p>

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/2018/07/28/Statement-of-Direction/"/>
1515
<id>http://blog.url.com/blog/2018/07/28/Statement-of-Direction/</id>
1616
<published>2018-07-28T09:47:00+01:00</published>
17-
<updated>2018-07-31T09:52:45+01:00</updated>
17+
<updated>2018-07-27T12:49:31+01:00</updated>
1818
<author>
1919
<name>Article Author</name>
2020
</author>
@@ -65,7 +65,7 @@
6565
<link rel="alternate" href="http://blog.url.com/blog/2018/07/26/hyperloop-2018-update/"/>
6666
<id>http://blog.url.com/blog/2018/07/26/hyperloop-2018-update/</id>
6767
<published>2018-07-26T09:47:00+01:00</published>
68-
<updated>2018-07-31T09:52:45+01:00</updated>
68+
<updated>2018-07-27T12:50:09+01:00</updated>
6969
<author>
7070
<name>Article Author</name>
7171
</author>
@@ -87,7 +87,7 @@
8787
<link rel="alternate" href="http://blog.url.com/blog/2017/02/28/spring-2017-comps-release/"/>
8888
<id>http://blog.url.com/blog/2017/02/28/spring-2017-comps-release/</id>
8989
<published>2017-02-28T00:00:00+00:00</published>
90-
<updated>2018-06-01T08:14:59+01:00</updated>
90+
<updated>2018-07-26T09:39:17+01:00</updated>
9191
<author>
9292
<name>Article Author</name>
9393
</author>
@@ -244,7 +244,7 @@
244244
<link rel="alternate" href="http://blog.url.com/blog/2017/01/28/editing-flux-loop-verses-decoupling/"/>
245245
<id>http://blog.url.com/blog/2017/01/28/editing-flux-loop-verses-decoupling/</id>
246246
<published>2017-01-28T00:00:00+00:00</published>
247-
<updated>2018-06-01T08:14:59+01:00</updated>
247+
<updated>2018-07-26T09:39:17+01:00</updated>
248248
<author>
249249
<name>Article Author</name>
250250
</author>
@@ -396,7 +396,7 @@ Yes. Note that Operations return promises, so asynchronous operation is assumed
396396
<link rel="alternate" href="http://blog.url.com/blog/2017/01/17/comparing-redux-with-hyperloop/"/>
397397
<id>http://blog.url.com/blog/2017/01/17/comparing-redux-with-hyperloop/</id>
398398
<published>2017-01-17T00:00:00+00:00</published>
399-
<updated>2018-06-01T08:14:59+01:00</updated>
399+
<updated>2018-07-26T09:39:17+01:00</updated>
400400
<author>
401401
<name>Article Author</name>
402402
</author>
@@ -728,7 +728,7 @@ return (
728728
<link rel="alternate" href="http://blog.url.com/blog/2016/09/08/Hyperloop-is-born/"/>
729729
<id>http://blog.url.com/blog/2016/09/08/Hyperloop-is-born/</id>
730730
<published>2016-09-08T06:50:00+01:00</published>
731-
<updated>2018-06-01T08:14:59+01:00</updated>
731+
<updated>2018-07-26T09:39:17+01:00</updated>
732732
<author>
733733
<name>Article Author</name>
734734
</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: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ <h4 id="step-1-1-installing-and-setting-up-the-webpacker-gem">Step 1.1 - Install
489489
<pre class="highlight ruby"><code><span class="n">bundle</span> <span class="n">update</span>
490490
</code></pre>
491491
<p>Run the webpacker install generator:</p>
492-
<pre class="highlight plaintext"><code>bin/rails webpacker:install
492+
<pre class="highlight plaintext"><code>bundle exec rails webpacker:install
493493
</code></pre>
494494
<h4 id="step-1-2-adding-libraries-into-webpack">Step 1.2 - Adding libraries into Webpack:</h4>
495495

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

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

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

521521
<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>
522522

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

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

560560
<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>
561561
<span class="n">config</span><span class="p">.</span><span class="nf">transport</span> <span class="o">=</span> <span class="ss">:simple_poller</span>
562+
563+
<span class="c1"># If your Webpacker version DO NOT generate Manifest files</span>
562564
<span class="n">config</span><span class="p">.</span><span class="nf">import</span> <span class="s1">'client_and_server'</span>
563565
<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>
566+
567+
<span class="c1"># If your Webpacker version DOES generate Manifest files</span>
568+
<span class="c1"># config.import Webpacker.manifest.lookup("client_and_server.js").split("/").last</span>
569+
<span class="c1"># config.import Webpacker.manifest.lookup("client_only.js").split("/").last</span>
564570
<span class="k">end</span>
565571
</code></pre>
566572
<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>
567573
<pre class="highlight erb"><code>#app/views/layouts/application.tml.erb
568574

569575
<span class="cp">&lt;%=</span> <span class="n">javascript_pack_tag</span> <span class="s1">'client_and_server'</span> <span class="cp">%&gt;</span>
570576
</code></pre>
577+
<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>
578+
571579
<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>
572580

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

0 commit comments

Comments
 (0)