Class: ReactiveRecord::WhileLoading
- Inherits:
-
Object
- Object
- ReactiveRecord::WhileLoading
show all
- Includes:
- React::Component, React::IsomorphicHelpers
- Defined in:
- lib/reactive_record/active_record/reactive_record/while_loading.rb
Overview
To notify React that something is loading use React::WhileLoading.loading! once everything is loaded then do React::WhileLoading.loaded_at message (typically a time stamp just for debug purposes)
Class Method Summary
collapse
Instance Method Summary
collapse
#component_did_mount, #component_did_update, #original_component_did_mount, #original_component_did_update, #reactive_record_link_set_while_loading_container_class, #reactive_record_link_to_enclosing_while_loading_container
Class Method Details
.add_style_sheet ⇒ Object
105
106
107
108
109
110
111
112
|
# File 'lib/reactive_record/active_record/reactive_record/while_loading.rb', line 105
def add_style_sheet
@style_sheet ||= %x{
$('<style type="text/css">'+
' .reactive_record_is_loading > .reactive_record_show_when_loaded { display: none; }'+
' .reactive_record_is_loaded > .reactive_record_show_while_loading { display: none; }'+
'</style>').appendTo("head")
}
end
|
.loaded_at(loaded_at) ⇒ Object
100
101
102
103
|
# File 'lib/reactive_record/active_record/reactive_record/while_loading.rb', line 100
def loaded_at(loaded_at)
React::State.set_state(self, :loaded_at, loaded_at)
@is_loading = false
end
|
.loading! ⇒ Object
94
95
96
97
98
|
# File 'lib/reactive_record/active_record/reactive_record/while_loading.rb', line 94
def loading!
React::RenderingContext.waiting_on_resources = true
React::State.get_state(self, :loaded_at)
@is_loading = true
end
|
.loading? ⇒ Boolean
90
91
92
|
# File 'lib/reactive_record/active_record/reactive_record/while_loading.rb', line 90
def loading?
@is_loading
end
|
Instance Method Details
#get_next_while_loading_counter ⇒ Object
63
64
65
|
# File 'lib/reactive_record/active_record/reactive_record/while_loading.rb', line 63
def get_next_while_loading_counter
@while_loading_counter += 1
end
|
#preload_css(css) ⇒ Object
67
68
69
|
# File 'lib/reactive_record/active_record/reactive_record/while_loading.rb', line 67
def preload_css(css)
@css_to_preload << css << "\n"
end
|
#render ⇒ Object
139
140
141
142
143
144
145
146
147
148
|
# File 'lib/reactive_record/active_record/reactive_record/while_loading.rb', line 139
def render
props = element_props.dup
classes = [props[:class], props[:className], "reactive_record_while_loading_container_#{@uniq_id}"].compact.join(" ")
props.merge!({
"data-reactive_record_while_loading_container_id" => @uniq_id,
"data-reactive_record_enclosing_while_loading_container_id" => @uniq_id,
class: classes
})
React.create_element(element_type, props) { loaded_children + loading_children }
end
|