File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,26 @@ def stream_react_component(component_name, options = {})
101101 )
102102 end
103103
104+ def stream_react_component_async ( component_name , options = { } )
105+ rendering_fiber = Fiber . new do
106+ stream = stream_react_component ( component_name , options )
107+ stream . each_chunk do |chunk |
108+ Fiber . yield chunk
109+ end
110+ Fiber . yield nil
111+ end
112+
113+ if @rorp_rendering_fibers . nil?
114+ raise ReactOnRails ::Error , "You must call stream_view_containing_react_components to render the view containing the react component"
115+ end
116+ @rorp_rendering_fibers << rendering_fiber
117+
118+ # return the first chunk of the fiber
119+ # It contains the initial html of the component
120+ # all updates will be appended to the stream sent to browser
121+ rendering_fiber . resume
122+ end
123+
104124 # react_component_hash is used to return multiple HTML strings for server rendering, such as for
105125 # adding meta-tags to a page.
106126 # It is exactly like react_component except for the following:
You can’t perform that action at this time.
0 commit comments