Class: Pakyow::UI::Framework

Inherits:
Object
  • Object
show all
Defined in:
lib/pakyow/ui/framework.rb

Defined Under Namespace

Modules: PresenterForContext

Instance Method Summary collapse

Instance Method Details

#bootObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/pakyow/ui/framework.rb', line 34

def boot
  object.class_eval do
    register_helper :passive, Application::Helpers::UI

    include Application::Behavior::UI::Recording
    include Application::Behavior::UI::Rendering
    include Application::Behavior::UI::Timeouts

    isolated :Renderer do
      include Presenter::Renderer::Behavior::UI::InstallTransforms
    end

    prepend PresenterForContext

    ui_renderer = Class.new(isolated(:Renderer)) do
      def marshal_load(state)
        deserialize(state)
        @presenter_class = @app.find_ui_presenter_for(@presenter_class)
        initialize_presenter
      end

      def perform(*)
        @presenter.to_html
      end
    end

    # Delete the render_components build step since ui will not be invoking the component.
    #
    ui_renderer.__build_fns.delete_if { |fn|
      fn.source_location[0].end_with?("render_components.rb")
    }

    unless const_defined?(:UIRenderer, false)
      const_set(:UIRenderer, ui_renderer)
    end

    after "initialize" do
      config.data.subscriptions.version = config.version
    end

    # @api private
    attr_reader :ui_executor
    unfreezable :ui_executor

    after "initialize" do
      @ui_executor = Concurrent::SingleThreadExecutor.new(
        auto_terminate: false,
      )
    end
  end
end