Class: React::Element

Inherits:
Object show all
Defined in:
lib/reactive_record/active_record/reactive_record/while_loading.rb

Instance Method Summary collapse

Instance Method Details

#hide_while_loadingObject



215
216
217
# File 'lib/reactive_record/active_record/reactive_record/while_loading.rb', line 215

def hide_while_loading
  while_loading
end

#while_loading(display = "", &loading_display_block) ⇒ Object



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/reactive_record/active_record/reactive_record/while_loading.rb', line 192

def while_loading(display = "", &loading_display_block)

  loaded_children = []
  loaded_children = block.call.dup if block

  loading_children = [display]
  loading_children = RenderingContext.build do |buffer|
    result = loading_display_block.call
    buffer << result.to_s if result.is_a? String
    buffer.dup
  end if loading_display_block
  RenderingContext.replace(
    self,
    React.create_element(
      ReactiveRecord::WhileLoading,
      loading: waiting_on_resources,
      loading_children: loading_children,
      loaded_children: loaded_children,
      element_type: type,
      element_props: properties)
    )
end