package org.aikodi.chameleon.core.element;

public class DescendantStream extends AbstractEventStream<Change,Element> implements EventListener<Change,Element> {

  private Element _element;

  public DescendantStream(Element element) {
    this._element = element;
  }

  @Override
  protected void activate() {
    _element.children().stream().forEach(c -> {
      EventStream<Change,Element> descendant = c.when().descendant();
      descendant.call(this);
    });
  }

  @Override
  protected void deactivate() {
    _element.children().stream().forEach(c -> {
      c.when().descendant().stopCalling(this);
    });
  }

  @Override
  public void accept(Event<? extends Change, ? extends Element> event) {
    send(event);
  }

}

@@ -191,278 +191,773 @@
 %0A  p
-ublic DescendantStream(Element element) %7B%0A    this._element = element;%0A  %7D%0A%0A  @Override%0A  protected void activate() %7B%0A    _element.children().stream().forEach(c -%3E %7B%0A      EventStream%3CChange,Element%3E descendant = c.when().descendant();%0A      descendant.call(this);%0A    %7D
+rivate EventListener%3C? super Added, ? super Element%3E _adder = c -%3E %7B%0A    c.change().element().when().any().call(this);%0A  %7D;%0A  private EventListener%3C? super Removed, ? super Element%3E _remover = c -%3E %7B%0A    c.change().element().when().any().stopCalling(this);%0A  %7D;%0A%0A  private EventStream%3CAdded, Element%3E _addStream;%0A%0A  private EventStream%3CRemoved, Element%3E _removeStream;%0A%0A  public DescendantStream(Element element) %7B%0A    this._element = element;%0A  %7D%0A%0A  @Override%0A  protected void activate() %7B%0A    _element.children().stream().forEach(c -%3E %7B%0A      c.when().any().call(this);%0A    %7D);%0A    _addStream = _element.when().self().about(Added.class);%0A    _addStream.call(_adder);%0A    _removeStream = _element.when().self().about(Removed.class);%0A    _removeStream.call(_remover
 );%0A 
@@ -1071,18 +1071,11 @@
 n().
-descend
 an
-t
+y
 ().s
@@ -1100,16 +1100,93 @@
     %7D);%0A
+    _addStream.stopCalling(_adder);%0A    _removeStream.stopCalling(_remover);%0A
   %7D%0A%0A  @

connect and disconnect to children