Module: ReactOnRails::RenderingStrategy Abstract

Included in:
ExecJsStrategy
Defined in:
lib/react_on_rails/rendering_strategy.rb,
lib/react_on_rails/rendering_strategy/exec_js_strategy.rb

Overview

This module is abstract.

Include this module and implement all instance methods in your concrete strategy class. Methods are instance methods, not class methods.

Strategy interface for server-side rendering. Concrete strategies implement the rendering pipeline (JS execution, caching, streaming) for a specific runtime (ExecJS, Node renderer, etc.).

Configured once at boot time via engine initializers, replacing runtime ‘react_on_rails_pro?` checks.

Part of the strategy pattern refactoring (see issue #2905). Currently additive — not yet wired into the main rendering path.

Defined Under Namespace

Classes: ExecJsStrategy

Instance Method Summary collapse

Instance Method Details

#execute(render_request) ⇒ Hash, Stream

Execute a server render. :nocov:

Parameters:

  • render_request (RenderRequest)

    The render request to execute

Returns:

  • (Hash, Stream)

    Result hash with “html”, “consoleReplayScript”, “hasErrors” keys, or a stream for streaming renders.

Raises:

  • (NotImplementedError)


24
25
26
# File 'lib/react_on_rails/rendering_strategy.rb', line 24

def execute(render_request)
  raise NotImplementedError, "#{self.class}#execute must be implemented"
end

#resetObject

Reset the rendering pool (e.g., after configuration changes). :nocov:

Raises:

  • (NotImplementedError)


31
32
33
# File 'lib/react_on_rails/rendering_strategy.rb', line 31

def reset
  raise NotImplementedError, "#{self.class}#reset must be implemented"
end

#reset_if_bundle_changedObject

Check if the server bundle has changed and reset the pool if so. Used in development mode to pick up bundle changes without restarting. :nocov:

Raises:

  • (NotImplementedError)


39
40
41
# File 'lib/react_on_rails/rendering_strategy.rb', line 39

def reset_if_bundle_changed
  raise NotImplementedError, "#{self.class}#reset_if_bundle_changed must be implemented"
end