Module: Hibiki::Owner

Included in:
Effect, Root
Defined in:
lib/hibiki/tracking.rb

Overview

---- shared owner behaviour --------------------------------------------------- Solid's Owner half of a computation: effects and roots own the child effects and cleanups registered while their block runs, and tear them down together on rerun/dispose.

Instance Method Summary collapse

Instance Method Details

#add_cleanup(block) ⇒ Object



103
# File 'lib/hibiki/tracking.rb', line 103

def add_cleanup(block) = (@cleanups ||= []) << block

#adopt(child) ⇒ Object

Effects created while our block runs become ours: when we re-run or are disposed, they are disposed too (Solid's owner tree). Otherwise a re-creating rerun would leak live duplicates.



101
# File 'lib/hibiki/tracking.rb', line 101

def adopt(child) = (@children ||= []) << child