reactive_rails_generator 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd400b8d05f2940350b712ef6d59e33c3fb454a9
|
4
|
+
data.tar.gz: 6846868648782263335a299501f55ab2d4acfd8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dce3d4e680b0878f56a7ded3b35746730e291c018ed424d31ae93fc99b4e685bb0c69c6624824988859520ccc18e8222d6cd6e59847c860c4eb76d8e17f5b0af
|
7
|
+
data.tar.gz: e9c20199e2aa797378ee630c988085ee90b28076fbc82680e1867ddf800fcc972e01319336ab8ac35ba5742d453efe8929648d7fe5fdf0508faa9dd6a211c137
|
@@ -9,7 +9,6 @@ module Reactrb
|
|
9
9
|
def inject_react_file_js
|
10
10
|
inject_into_file 'app/assets/javascripts/application.js', after: "// about supported directives.\n" do <<-'JS'
|
11
11
|
//= require 'components'
|
12
|
-
//= require 'react'
|
13
12
|
//= require 'react_ujs'
|
14
13
|
JS
|
15
14
|
end
|
@@ -36,14 +35,15 @@ JS
|
|
36
35
|
# app/react/components.rb
|
37
36
|
require 'opal'
|
38
37
|
require 'reactive-ruby'
|
38
|
+
require 'react'
|
39
39
|
if React::IsomorphicHelpers.on_opal_client?
|
40
40
|
require 'opal-jquery'
|
41
41
|
require 'browser'
|
42
42
|
require 'browser/interval'
|
43
43
|
require 'browser/delay'
|
44
|
-
# add any requires that can ONLY run on client here
|
44
|
+
# add any additional requires that can ONLY run on client here
|
45
45
|
end
|
46
|
-
#{"require 'reactive-router'" if options[:"reactive-router"] || options[:all]}
|
46
|
+
#{"require 'reactive-router'\nrequire 'react_router'" if options[:"reactive-router"] || options[:all]}
|
47
47
|
#{"require 'reactive-record'" if options[:"reactive-record"] || options[:all]}
|
48
48
|
#{"require 'models'" if options[:"reactive-record"] || options[:all]}
|
49
49
|
require_tree './components'
|
@@ -74,7 +74,10 @@ require_tree './models'
|
|
74
74
|
gem 'therubyracer', platforms: :ruby
|
75
75
|
|
76
76
|
# optional gems
|
77
|
-
|
77
|
+
if options[:"reactive-router"] || options[:all]
|
78
|
+
gem 'react-router-rails', '~>0.13.3'
|
79
|
+
gem 'reactive-router'
|
80
|
+
end
|
78
81
|
gem 'reactive-record' if options[:"reactive-record"] || options[:all]
|
79
82
|
end
|
80
83
|
end
|
@@ -1,12 +1,40 @@
|
|
1
1
|
module Components
|
2
2
|
<%- @modules.each do |module_name| %><%= " "* @indet %>module <%= module_name.camelize %><%- @indet += 1 %>
|
3
3
|
<%- end %><%=" "* @indet %>class <%= @file_name %> < React::Component::Base
|
4
|
+
|
4
5
|
<%=" "* @indet %># param :my_param
|
6
|
+
<%=" "* @indet %># param param_with_default: "default value"
|
7
|
+
<%=" "* @indet %># param :param_with_default2, default: "default value" # alternative syntax
|
8
|
+
<%=" "* @indet %># param :param_with_type, type: Hash
|
9
|
+
<%=" "* @indet %># param :array_of_hashes, type: [Hash]
|
10
|
+
<%=" "* @indet %># collect_all_other_params_as :attributes #collects all other params into a hash
|
11
|
+
|
12
|
+
<%=" "* @indet %># The following are the most common lifecycle call backs,
|
13
|
+
<%=" "* @indet %># the following are the most common lifecycle call backs# delete any that you are not using.
|
14
|
+
<%=" "* @indet %># call backs may also reference an instance method i.e. before_mount :my_method
|
15
|
+
|
16
|
+
<%=" "* @indet %>before_mount do
|
17
|
+
<%=" "* @indet %> # any initialization particularly of state variables goes here.
|
18
|
+
<%=" "* @indet %> # this will execute on server (prerendering) and client.
|
19
|
+
<%=" "* @indet %>end
|
20
|
+
|
21
|
+
<%=" "* @indet %>after_mount do
|
22
|
+
<%=" "* @indet %> # any client only post rendering initialization goes here.
|
23
|
+
<%=" "* @indet %> # i.e. start timers, HTTP requests, and low level jquery operations etc.
|
24
|
+
<%=" "* @indet %>end
|
25
|
+
|
26
|
+
<%=" "* @indet %>before_update do
|
27
|
+
<%=" "* @indet %> # called whenever a component will be re-rerendered
|
28
|
+
<%=" "* @indet %>end
|
29
|
+
|
30
|
+
<%=" "* @indet %>before_unmount do
|
31
|
+
<%=" "* @indet %> # cleanup any thing (i.e. timers) before component is destroyed
|
32
|
+
<%=" "* @indet %>end
|
5
33
|
|
6
34
|
<%=" "* @indet %>def render
|
7
|
-
<%=" "* @indet %>
|
8
|
-
<%=" "* @indet %>
|
9
|
-
<%=" "* @indet %>
|
35
|
+
<%=" "* @indet %> div do
|
36
|
+
<%=" "* @indet %> "<%= (@modules+[@file_name]).join('::') %>"
|
37
|
+
<%=" "* @indet %> end
|
10
38
|
<%=" "* @indet %>end
|
11
39
|
<%=" "* @indet %>end
|
12
40
|
<%- @modules.each do %><%- @indet -= 1 %><%=" "* @indet %>end
|