Class: Hibiki::Root

Inherits:
Object
  • Object
show all
Includes:
Owner
Defined in:
lib/hibiki/root.rb

Overview

---- root ------------------------------------------------------------------- Solid's createRoot: an ownership scope that is not an effect. Effects and cleanups created inside the block belong to the root and live until #dispose — the lifecycle anchor for long-lived graphs (a session, a connection) whose teardown is an external event, not a rerun.

Deliberately detached: a root created inside a running effect is NOT adopted, so the enclosing effect's rerun/disposal leaves it alone (Solid's escape hatch from the owner tree). Whoever holds the root disposes it.

The block runs untracked (Solid clears the Listener in createRoot): a root built mid-effect must not subscribe that effect to signals it reads.

Instance Method Summary collapse

Methods included from Owner

#add_cleanup, #adopt

Constructor Details

#initialize(&block) ⇒ Root

Returns a new instance of Root.



21
22
23
24
25
26
# File 'lib/hibiki/root.rb', line 21

def initialize(&block)
  @disposed = false
  Hibiki.own(self) do
    Hibiki.untrack { block.call(self) }
  end
end

Instance Method Details

#disposeObject



30
31
32
33
34
35
# File 'lib/hibiki/root.rb', line 30

def dispose
  return if @disposed

  @disposed = true
  dispose_owned
end

#disposed?Boolean

Returns:

  • (Boolean)


28
# File 'lib/hibiki/root.rb', line 28

def disposed? = @disposed