isomorfeus-react 16.13.11 → 16.13.12

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.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -1
  3. data/lib/isomorfeus/react/config.rb +189 -189
  4. data/lib/isomorfeus/react/memcached_component_cache.rb +19 -19
  5. data/lib/isomorfeus/react/redis_component_cache.rb +19 -19
  6. data/lib/isomorfeus/react/thread_local_component_cache.rb +15 -15
  7. data/lib/isomorfeus/react_view_helper.rb +231 -231
  8. data/lib/isomorfeus/top_level.rb +103 -103
  9. data/lib/isomorfeus/top_level_ssr.rb +42 -42
  10. data/lib/isomorfeus-react-material-ui.rb +4 -4
  11. data/lib/isomorfeus-react-native.rb +5 -5
  12. data/lib/isomorfeus-react-paper.rb +4 -4
  13. data/lib/isomorfeus-react.rb +120 -120
  14. data/lib/isomorfeus_react/lucid_app/api.rb +26 -26
  15. data/lib/isomorfeus_react/lucid_app/base.rb +7 -7
  16. data/lib/isomorfeus_react/lucid_app/mixin.rb +23 -23
  17. data/lib/isomorfeus_react/lucid_app/native_component_constructor.rb +48 -48
  18. data/lib/isomorfeus_react/lucid_app/native_lucid_component_constructor.rb +94 -95
  19. data/lib/isomorfeus_react/lucid_component/api.rb +75 -75
  20. data/lib/isomorfeus_react/lucid_component/app_store_proxy.rb +37 -37
  21. data/lib/isomorfeus_react/lucid_component/base.rb +7 -7
  22. data/lib/isomorfeus_react/lucid_component/class_store_proxy.rb +44 -44
  23. data/lib/isomorfeus_react/lucid_component/initializer.rb +14 -14
  24. data/lib/isomorfeus_react/lucid_component/instance_store_proxy.rb +44 -44
  25. data/lib/isomorfeus_react/lucid_component/mixin.rb +22 -22
  26. data/lib/isomorfeus_react/lucid_component/native_component_constructor.rb +35 -35
  27. data/lib/isomorfeus_react/lucid_component/native_lucid_component_constructor.rb +82 -83
  28. data/lib/isomorfeus_react/lucid_component/styles_api.rb +34 -34
  29. data/lib/isomorfeus_react/lucid_func/base.rb +7 -7
  30. data/lib/isomorfeus_react/lucid_func/initializer.rb +11 -11
  31. data/lib/isomorfeus_react/lucid_func/mixin.rb +18 -18
  32. data/lib/isomorfeus_react/lucid_func/native_component_constructor.rb +81 -81
  33. data/lib/isomorfeus_react/react/function_component/api.rb +105 -105
  34. data/lib/isomorfeus_react/react/function_component/base.rb +8 -8
  35. data/lib/isomorfeus_react/react/function_component/initializer.rb +10 -10
  36. data/lib/isomorfeus_react/react/function_component/mixin.rb +17 -17
  37. data/lib/isomorfeus_react/react/function_component/native_component_constructor.rb +48 -48
  38. data/lib/isomorfeus_react/react/memo_component/base.rb +8 -8
  39. data/lib/isomorfeus_react/react/memo_component/mixin.rb +17 -17
  40. data/lib/isomorfeus_react/react/memo_component/native_component_constructor.rb +49 -49
  41. data/lib/isomorfeus_react_material/lucid_material/app/base.rb +8 -8
  42. data/lib/isomorfeus_react_material/lucid_material/app/mixin.rb +20 -20
  43. data/lib/isomorfeus_react_material/lucid_material/app/native_component_constructor.rb +50 -50
  44. data/lib/isomorfeus_react_material/lucid_material/component/base.rb +9 -9
  45. data/lib/isomorfeus_react_material/lucid_material/component/mixin.rb +19 -19
  46. data/lib/isomorfeus_react_material/lucid_material/component/native_component_constructor.rb +36 -36
  47. data/lib/isomorfeus_react_material/lucid_material/func/base.rb +9 -9
  48. data/lib/isomorfeus_react_material/lucid_material/func/mixin.rb +15 -15
  49. data/lib/isomorfeus_react_material/lucid_material/func/native_component_constructor.rb +83 -83
  50. data/lib/isomorfeus_react_paper/lucid_paper/app/base.rb +9 -9
  51. data/lib/isomorfeus_react_paper/lucid_paper/app/mixin.rb +19 -19
  52. data/lib/isomorfeus_react_paper/lucid_paper/app/native_component_constructor.rb +32 -32
  53. data/lib/isomorfeus_react_paper/lucid_paper/component/base.rb +9 -9
  54. data/lib/isomorfeus_react_paper/lucid_paper/component/mixin.rb +18 -18
  55. data/lib/isomorfeus_react_paper/lucid_paper/component/native_component_constructor.rb +25 -25
  56. data/lib/isomorfeus_react_paper/lucid_paper/func/base.rb +9 -9
  57. data/lib/isomorfeus_react_paper/lucid_paper/func/mixin.rb +14 -14
  58. data/lib/isomorfeus_react_paper/lucid_paper/func/native_component_constructor.rb +71 -71
  59. data/lib/lucid_app/context.rb +7 -7
  60. data/lib/lucid_prop_declaration/mixin.rb +126 -126
  61. data/lib/react/children.rb +34 -34
  62. data/lib/react/component/api.rb +134 -134
  63. data/lib/react/component/base.rb +8 -8
  64. data/lib/react/component/callbacks.rb +115 -115
  65. data/lib/react/component/elements.rb +60 -60
  66. data/lib/react/component/features.rb +48 -48
  67. data/lib/react/component/history.rb +69 -65
  68. data/lib/react/component/initializer.rb +11 -11
  69. data/lib/react/component/location.rb +19 -15
  70. data/lib/react/component/match.rb +35 -31
  71. data/lib/react/component/mixin.rb +20 -20
  72. data/lib/react/component/native_component_constructor.rb +69 -70
  73. data/lib/react/component/props.rb +83 -83
  74. data/lib/react/component/resolution.rb +97 -97
  75. data/lib/react/component/state.rb +58 -54
  76. data/lib/react/component/styles.rb +66 -66
  77. data/lib/react/context_wrapper.rb +48 -44
  78. data/lib/react/native_constant_wrapper.rb +29 -29
  79. data/lib/react/ref.rb +16 -12
  80. data/lib/react/synthetic_event.rb +52 -52
  81. data/lib/react/version.rb +3 -3
  82. data/lib/react.rb +296 -296
  83. data/lib/react_dom.rb +41 -41
  84. data/lib/react_dom_server.rb +18 -18
  85. data/lib/react_native/component/elements.rb +203 -203
  86. data/lib/react_native/lucid_app/react_native_component_constructor.rb +51 -51
  87. data/lib/react_native/lucid_component/react_native_component_constructor.rb +37 -37
  88. data/lib/react_native/lucid_func/react_native_component_constructor.rb +82 -82
  89. data/lib/react_native/react.rb +120 -120
  90. metadata +23 -17
@@ -1,23 +1,23 @@
1
- module LucidApp
2
- module Mixin
3
- def self.included(base)
4
- base.include(::Native::Wrapper)
5
- base.extend(::LucidApp::NativeLucidComponentConstructor)
6
- if on_browser? || on_ssr?
7
- base.extend(::LucidApp::NativeComponentConstructor)
8
- base.include(::React::Component::Elements)
9
- elsif on_mobile?
10
- base.extend(::LucidApp::ReactNativeComponentConstructor)
11
- base.include(::ReactNative::Component::Elements)
12
- end
13
- base.extend(::LucidPropDeclaration::Mixin)
14
- base.include(::React::Component::Api)
15
- base.include(::React::Component::Callbacks)
16
- base.include(::LucidComponent::Api)
17
- base.include(::LucidComponent::StylesApi)
18
- base.include(::LucidApp::Api)
19
- base.include(::LucidComponent::Initializer)
20
- base.include(::React::Component::Features)
21
- end
22
- end
23
- end
1
+ module LucidApp
2
+ module Mixin
3
+ def self.included(base)
4
+ base.include(::Native::Wrapper)
5
+ base.extend(::LucidApp::NativeLucidComponentConstructor)
6
+ if on_browser? || on_ssr?
7
+ base.extend(::LucidApp::NativeComponentConstructor)
8
+ base.include(::React::Component::Elements)
9
+ elsif on_mobile?
10
+ base.extend(::LucidApp::ReactNativeComponentConstructor)
11
+ base.include(::ReactNative::Component::Elements)
12
+ end
13
+ base.extend(::LucidPropDeclaration::Mixin)
14
+ base.include(::React::Component::Api)
15
+ base.include(::React::Component::Callbacks)
16
+ base.include(::LucidComponent::Api)
17
+ base.include(::LucidComponent::StylesApi)
18
+ base.include(::LucidApp::Api)
19
+ base.include(::LucidComponent::Initializer)
20
+ base.include(::React::Component::Features)
21
+ end
22
+ end
23
+ end
@@ -1,48 +1,48 @@
1
- module LucidApp
2
- module NativeComponentConstructor
3
- # for should_component_update we apply ruby semantics for comparing props
4
- # to do so, we convert the props to ruby hashes and then compare
5
- # this makes sure, that for example rubys Nil object gets handled properly
6
- def self.extended(base)
7
- theme_component_name = base.to_s + 'ThemeWrapper'
8
- # language=JS
9
- %x{
10
- base.jss_theme = {};
11
- base.themed_react_component = function(props) {
12
- let opag = Opal.global;
13
- let classes = null;
14
- let theme = opag.ReactJSS.useTheme();
15
- if (base.jss_styles) {
16
- if (!base.use_styles || (Opal.Isomorfeus.development === true)) {
17
- let styles;
18
- if (typeof base.jss_styles === 'function') { styles = base.jss_styles(theme); }
19
- else { styles = base.jss_styles; }
20
- base.use_styles = opag.ReactJSS.createUseStyles(styles);
21
- }
22
- classes = base.use_styles();
23
- }
24
- let themed_classes_props = Object.assign({}, props, { classes: classes, theme: theme });
25
- return opag.React.createElement(base.lucid_react_component, themed_classes_props);
26
- };
27
- base.themed_react_component.displayName = #{theme_component_name};
28
- base.react_component = class extends Opal.global.React.Component {
29
- constructor(props) {
30
- super(props);
31
- if (Opal.Isomorfeus.$top_component() == nil) { Opal.Isomorfeus['$top_component='](this); }
32
- }
33
- static get displayName() {
34
- return "IsomorfeusTopLevelComponent";
35
- }
36
- static set displayName(new_name) {
37
- // dont do anything here except returning the set value
38
- return new_name;
39
- }
40
- render() {
41
- let themed_component = Opal.global.React.createElement(base.themed_react_component, this.props);
42
- return Opal.global.React.createElement(Opal.global.ReactJSS.ThemeProvider, { theme: base.jss_theme }, themed_component);
43
- }
44
- }
45
- }
46
- end
47
- end
48
- end
1
+ module LucidApp
2
+ module NativeComponentConstructor
3
+ # for should_component_update we apply ruby semantics for comparing props
4
+ # to do so, we convert the props to ruby hashes and then compare
5
+ # this makes sure, that for example rubys Nil object gets handled properly
6
+ def self.extended(base)
7
+ theme_component_name = base.to_s + 'ThemeWrapper'
8
+ # language=JS
9
+ %x{
10
+ base.jss_theme = {};
11
+ base.themed_react_component = function(props) {
12
+ let opag = Opal.global;
13
+ let classes = null;
14
+ let theme = opag.ReactJSS.useTheme();
15
+ if (base.jss_styles) {
16
+ if (!base.use_styles || (Opal.Isomorfeus.development === true)) {
17
+ let styles;
18
+ if (typeof base.jss_styles === 'function') { styles = base.jss_styles(theme); }
19
+ else { styles = base.jss_styles; }
20
+ base.use_styles = opag.ReactJSS.createUseStyles(styles);
21
+ }
22
+ classes = base.use_styles();
23
+ }
24
+ let themed_classes_props = Object.assign({}, props, { classes: classes, theme: theme });
25
+ return opag.React.createElement(base.lucid_react_component, themed_classes_props);
26
+ };
27
+ base.themed_react_component.displayName = #{theme_component_name};
28
+ base.react_component = class extends Opal.global.React.Component {
29
+ constructor(props) {
30
+ super(props);
31
+ if (Opal.Isomorfeus.$top_component() == nil) { Opal.Isomorfeus['$top_component='](this); }
32
+ }
33
+ static get displayName() {
34
+ return "IsomorfeusTopLevelComponent";
35
+ }
36
+ static set displayName(new_name) {
37
+ // dont do anything here except returning the set value
38
+ return new_name;
39
+ }
40
+ render() {
41
+ let themed_component = Opal.global.React.createElement(base.themed_react_component, this.props);
42
+ return Opal.global.React.createElement(Opal.global.ReactJSS.ThemeProvider, { theme: base.jss_theme }, themed_component);
43
+ }
44
+ }
45
+ }
46
+ end
47
+ end
48
+ end
@@ -1,95 +1,94 @@
1
- module LucidApp
2
- module NativeLucidComponentConstructor
3
- # for should_component_update we apply ruby semantics for comparing props
4
- # to do so, we convert the props to ruby hashes and then compare
5
- # this makes sure, that for example rubys Nil object gets handled properly
6
- def self.extended(base)
7
- component_name = base.to_s
8
- # language=JS
9
- %x{
10
- base.lucid_react_component = class extends Opal.global.React.Component {
11
- constructor(props) {
12
- super(props);
13
- const oper = Opal.React;
14
- if (base.$default_state_defined()) {
15
- this.state = base.$state().$to_n();
16
- } else {
17
- this.state = {};
18
- };
19
- this.state.isomorfeus_store_state = Opal.Isomorfeus.store.native.getState();
20
- var current_store_state = this.state.isomorfeus_store_state;
21
- if (typeof current_store_state.class_state[#{component_name}] !== "undefined") {
22
- this.state.class_state = {};
23
- this.state.class_state[#{component_name}] = current_store_state.class_state[#{component_name}];
24
- } else {
25
- this.state.class_state = {};
26
- this.state.class_state[#{component_name}] = {};
27
- };
28
- this.__ruby_instance = base.$new(this);
29
- var defined_refs = #{base.defined_refs};
30
- for (var ref in defined_refs) {
31
- if (defined_refs[ref] != null) {
32
- this[ref] = function(element) {
33
- element = oper.native_element_or_component_to_ruby(element);
34
- #{`this.__ruby_instance`.instance_exec(`element`, &`defined_refs[ref]`)}
35
- }
36
- this[ref] = this[ref].bind(this);
37
- } else {
38
- this[ref] = Opal.global.React.createRef();
39
- }
40
- }
41
- if (base.preload_block) {
42
- oper.active_redux_components.push(this);
43
- this.state.preloaded = this.__ruby_instance.$execute_preload_block();
44
- oper.active_redux_components.pop();
45
- }
46
- this.listener = this.listener.bind(this);
47
- this.unsubscriber = Opal.Isomorfeus.store.native.subscribe(this.listener);
48
- }
49
- static get displayName() {
50
- return #{component_name};
51
- }
52
- static set displayName(new_name) {
53
- // dont do anything here except returning the set value
54
- return new_name;
55
- }
56
- render() {
57
- const oper = Opal.React;
58
- oper.render_buffer.push([]);
59
- // console.log("lucid app pushed", oper.render_buffer, oper.render_buffer.toString());
60
- oper.active_components.push(this);
61
- oper.active_redux_components.push(this);
62
- let block_result;
63
- if (base.while_loading_block && !this.state.preloaded) { block_result = #{`this.__ruby_instance`.instance_exec(&`base.while_loading_block`)}; }
64
- else { block_result = #{`this.__ruby_instance`.instance_exec(&`base.render_block`)}; }
65
- if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
66
- oper.active_redux_components.pop();
67
- oper.active_components.pop();
68
- let children = oper.render_buffer.pop();
69
- // console.log("lucid app popping", oper.render_buffer, oper.render_buffer.toString());
70
- return Opal.global.React.createElement.apply(this, [Opal.global.LucidApplicationContext.Provider, { value: this.state.isomorfeus_store_state }].concat(children));
71
- }
72
- data_access() {
73
- this.state.isomorfeus_store_state;
74
- }
75
- listener() {
76
- let next_state = Opal.Isomorfeus.store.native.getState();
77
- this.setState({ isomorfeus_store_state: next_state });
78
- }
79
- componentWillUnmount() {
80
- if (typeof this.unsubscriber === "function") { this.unsubscriber(); }
81
- }
82
- validateProp(props, propName, componentName) {
83
- try { base.$validate_prop(propName, props[propName]) }
84
- catch (e) { return new Error(componentName + ": Error: prop validation failed: " + e.message); }
85
- return null;
86
- }
87
- }
88
- base.preload_block = null;
89
- base.while_loading_block = null;
90
- base.jss_styles = null;
91
- base.use_styles = null;
92
- }
93
- end
94
- end
95
- end
1
+ module LucidApp
2
+ module NativeLucidComponentConstructor
3
+ # for should_component_update we apply ruby semantics for comparing props
4
+ # to do so, we convert the props to ruby hashes and then compare
5
+ # this makes sure, that for example rubys Nil object gets handled properly
6
+ def self.extended(base)
7
+ component_name = base.to_s
8
+ %x{
9
+ base.lucid_react_component = class extends Opal.global.React.Component {
10
+ constructor(props) {
11
+ super(props);
12
+ const oper = Opal.React;
13
+ if (base.$default_state_defined()) {
14
+ this.state = base.$state().$to_n();
15
+ } else {
16
+ this.state = {};
17
+ };
18
+ this.state.isomorfeus_store_state = Opal.Isomorfeus.store.native.getState();
19
+ var current_store_state = this.state.isomorfeus_store_state;
20
+ if (typeof current_store_state.class_state[#{component_name}] !== "undefined") {
21
+ this.state.class_state = {};
22
+ this.state.class_state[#{component_name}] = current_store_state.class_state[#{component_name}];
23
+ } else {
24
+ this.state.class_state = {};
25
+ this.state.class_state[#{component_name}] = {};
26
+ };
27
+ this.__ruby_instance = base.$new(this);
28
+ var defined_refs = #{base.defined_refs};
29
+ for (var ref in defined_refs) {
30
+ if (defined_refs[ref] != null) {
31
+ this[ref] = function(element) {
32
+ element = oper.native_element_or_component_to_ruby(element);
33
+ #{`this.__ruby_instance`.instance_exec(`element`, &`defined_refs[ref]`)}
34
+ }
35
+ this[ref] = this[ref].bind(this);
36
+ } else {
37
+ this[ref] = Opal.global.React.createRef();
38
+ }
39
+ }
40
+ if (base.preload_block) {
41
+ oper.active_redux_components.push(this);
42
+ this.state.preloaded = this.__ruby_instance.$execute_preload_block();
43
+ oper.active_redux_components.pop();
44
+ }
45
+ this.listener = this.listener.bind(this);
46
+ this.unsubscriber = Opal.Isomorfeus.store.native.subscribe(this.listener);
47
+ }
48
+ static get displayName() {
49
+ return #{component_name};
50
+ }
51
+ static set displayName(new_name) {
52
+ // dont do anything here except returning the set value
53
+ return new_name;
54
+ }
55
+ render() {
56
+ const oper = Opal.React;
57
+ oper.render_buffer.push([]);
58
+ // console.log("lucid app pushed", oper.render_buffer, oper.render_buffer.toString());
59
+ oper.active_components.push(this);
60
+ oper.active_redux_components.push(this);
61
+ let block_result;
62
+ if (base.while_loading_block && !this.state.preloaded) { block_result = #{`this.__ruby_instance`.instance_exec(&`base.while_loading_block`)}; }
63
+ else { block_result = #{`this.__ruby_instance`.instance_exec(&`base.render_block`)}; }
64
+ if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
65
+ oper.active_redux_components.pop();
66
+ oper.active_components.pop();
67
+ let children = oper.render_buffer.pop();
68
+ // console.log("lucid app popping", oper.render_buffer, oper.render_buffer.toString());
69
+ return Opal.global.React.createElement.apply(this, [Opal.global.LucidApplicationContext.Provider, { value: this.state.isomorfeus_store_state }].concat(children));
70
+ }
71
+ data_access() {
72
+ this.state.isomorfeus_store_state;
73
+ }
74
+ listener() {
75
+ let next_state = Opal.Isomorfeus.store.native.getState();
76
+ this.setState({ isomorfeus_store_state: next_state });
77
+ }
78
+ componentWillUnmount() {
79
+ if (typeof this.unsubscriber === "function") { this.unsubscriber(); }
80
+ }
81
+ validateProp(props, propName, componentName) {
82
+ try { base.$validate_prop(propName, props[propName]) }
83
+ catch (e) { return new Error(componentName + ": Error: prop validation failed: " + e.message); }
84
+ return null;
85
+ }
86
+ }
87
+ base.preload_block = null;
88
+ base.while_loading_block = null;
89
+ base.jss_styles = null;
90
+ base.use_styles = null;
91
+ }
92
+ end
93
+ end
94
+ end
@@ -1,75 +1,75 @@
1
- module LucidComponent
2
- module Api
3
- def self.included(base)
4
- base.instance_exec do
5
- # store
6
- attr_accessor :app_store
7
- attr_accessor :class_store
8
- attr_accessor :store
9
-
10
- def class_store
11
- @class_store ||= ::LucidComponent::ClassStoreProxy.new(self.to_s)
12
- end
13
-
14
- def store_updates(switch)
15
- case switch
16
- when :on then `base.store_updates = true`
17
- when :off then `base.store_updates = false`
18
- end
19
- end
20
-
21
- # preloading
22
- def preload(&block)
23
- `base.preload_block = block`
24
- component_did_mount do
25
- unless self.state.preloaded
26
- @_preload_promise.then { self.state.preloaded = true }.fail do |result|
27
- err_text = "#{self.class.name}: preloading failed, last result: #{result.nil? ? 'nil' : result}!"
28
- `console.error(err_text)`
29
- end
30
- end
31
- end
32
- end
33
-
34
- def while_loading(option = nil, &block)
35
- wl_block = proc do
36
- if @_preload_promise.resolved?
37
- instance_exec(&`base.render_block`)
38
- else
39
- instance_exec(&block)
40
- end
41
- end
42
- `base.while_loading_block = wl_block`
43
- end
44
- end
45
-
46
- # stores
47
- def local_store
48
- LocalStore
49
- end
50
-
51
- def session_store
52
- SessionStore
53
- end
54
-
55
- def theme
56
- props.theme
57
- end
58
-
59
- # preloading
60
- def execute_preload_block
61
- @_preload_promise = instance_exec(&self.class.JS[:preload_block])
62
- @_preload_promise.resolved?
63
- end
64
-
65
- def preloaded?
66
- !!state.preloaded
67
- end
68
-
69
- # requires transport
70
- def current_user
71
- Isomorfeus.current_user
72
- end
73
- end
74
- end
75
- end
1
+ module LucidComponent
2
+ module Api
3
+ def self.included(base)
4
+ base.instance_exec do
5
+ # store
6
+ attr_accessor :app_store
7
+ attr_accessor :class_store
8
+ attr_accessor :store
9
+
10
+ def class_store
11
+ @class_store ||= ::LucidComponent::ClassStoreProxy.new(self.to_s)
12
+ end
13
+
14
+ def store_updates(switch)
15
+ case switch
16
+ when :on then `base.store_updates = true`
17
+ when :off then `base.store_updates = false`
18
+ end
19
+ end
20
+
21
+ # preloading
22
+ def preload(&block)
23
+ `base.preload_block = block`
24
+ component_did_mount do
25
+ unless self.state.preloaded
26
+ @_preload_promise.then { self.state.preloaded = true }.fail do |result|
27
+ err_text = "#{self.class.name}: preloading failed, last result: #{result.nil? ? 'nil' : result}!"
28
+ `console.error(err_text)`
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ def while_loading(option = nil, &block)
35
+ wl_block = proc do
36
+ if @_preload_promise.resolved?
37
+ instance_exec(&`base.render_block`)
38
+ else
39
+ instance_exec(&block)
40
+ end
41
+ end
42
+ `base.while_loading_block = wl_block`
43
+ end
44
+ end
45
+
46
+ # stores
47
+ def local_store
48
+ LocalStore
49
+ end
50
+
51
+ def session_store
52
+ SessionStore
53
+ end
54
+
55
+ def theme
56
+ props.theme
57
+ end
58
+
59
+ # preloading
60
+ def execute_preload_block
61
+ @_preload_promise = instance_exec(&self.class.JS[:preload_block])
62
+ @_preload_promise.resolved?
63
+ end
64
+
65
+ def preloaded?
66
+ !!state.preloaded
67
+ end
68
+
69
+ # requires transport
70
+ def current_user
71
+ Isomorfeus.current_user
72
+ end
73
+ end
74
+ end
75
+ end
@@ -1,37 +1,37 @@
1
- module LucidComponent
2
- class AppStoreProxy
3
- def initialize(component_instance)
4
- if component_instance
5
- @native = component_instance.to_n
6
- @component_instance = component_instance
7
- end
8
- end
9
-
10
- def [](key)
11
- method_missing(key)
12
- end
13
-
14
- def []=(key, value)
15
- method_missing(key, value)
16
- end
17
-
18
- def method_missing(key, *args, &block)
19
- if `args.length > 0`
20
- # set class state, simply a dispatch
21
- action = { type: 'APPLICATION_STATE', name: (`key.endsWith('=')` ? key.chop : key), value: args[0] }
22
- Isomorfeus.store.collect_and_defer_dispatch(action)
23
- else
24
- # check if we have a component local state value
25
- if @native && `#@native.props.store`
26
- if `#@native.props.store.application_state && #@native.props.store.application_state.hasOwnProperty(key)`
27
- return @native.JS[:props].JS[:store].JS[:application_state].JS[key]
28
- end
29
- else
30
- return AppStore[key]
31
- end
32
- # otherwise return nil
33
- return nil
34
- end
35
- end
36
- end
37
- end
1
+ module LucidComponent
2
+ class AppStoreProxy
3
+ def initialize(component_instance)
4
+ if component_instance
5
+ @native = component_instance.to_n
6
+ @component_instance = component_instance
7
+ end
8
+ end
9
+
10
+ def [](key)
11
+ method_missing(key)
12
+ end
13
+
14
+ def []=(key, value)
15
+ method_missing(key, value)
16
+ end
17
+
18
+ def method_missing(key, *args, &block)
19
+ if `args.length > 0`
20
+ # set class state, simply a dispatch
21
+ action = { type: 'APPLICATION_STATE', name: (`key.endsWith('=')` ? key.chop : key), value: args[0] }
22
+ Isomorfeus.store.collect_and_defer_dispatch(action)
23
+ else
24
+ # check if we have a component local state value
25
+ if @native && `#@native.props.store`
26
+ if `#@native.props.store.application_state && #@native.props.store.application_state.hasOwnProperty(key)`
27
+ return @native.JS[:props].JS[:store].JS[:application_state].JS[key]
28
+ end
29
+ else
30
+ return AppStore[key]
31
+ end
32
+ # otherwise return nil
33
+ return nil
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,7 +1,7 @@
1
- module LucidComponent
2
- class Base
3
- def self.inherited(base)
4
- base.include(::LucidComponent::Mixin)
5
- end
6
- end
7
- end
1
+ module LucidComponent
2
+ class Base
3
+ def self.inherited(base)
4
+ base.include(::LucidComponent::Mixin)
5
+ end
6
+ end
7
+ end