package arez.doc.examples.at_component_dependency;

import arez.annotations.ArezComponent;
import arez.annotations.ComponentDependency;
import arez.annotations.Observable;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

@ArezComponent
public abstract class PersonViewModel
{
  @Nonnull
  private final Person _person;
  //DOC ELIDE START

  public PersonViewModel( @Nonnull final Person person )
  {
    _person = person;
  }

  //DOC ELIDE END

  // Let imagine there is a lot more logic and state on the view model
  // to justify it's existence rather than just having view layer directly
  // accessing underlying entities

  @ComponentDependency
  @Nonnull
  public final Person getPerson()
  {
    // This reference is immutable and the network replication
    // layer is responsible for managing the lifecycle of person
    // component and may dispose it when the Person entity is deleted
    // on the server which should trigger this view model being disposed.
    return _person;
  }

  /**
   * The Job entity is likewise controlled by the server
   * and can be updated, removed on the server and replicated to the web
   * browser. In this scenario the current job is just removed from the
   * person view model.
   */
  @ComponentDependency( action = ComponentDependency.Action.SET_NULL )
  @Observable
  @Nullable
  public abstract Job getCurrentJob();
  //DOC ELIDE START

  public abstract void setCurrentJob( @Nullable final Job currentJob );
  //DOC ELIDE END
}

@@ -290,16 +290,303 @@
 del%0A%7B%0A  
+// This reference is immutable and the network replication%0A  // layer is responsible for managing the lifecycle of person%0A  // component and may dispose it when the Person entity is deleted%0A  // on the server which should trigger this view model being disposed.%0A  @ComponentDependency%0A  
 @Nonnull
@@ -591,16 +591,8 @@
 ll%0A 
- private
  fin
@@ -920,39 +920,16 @@
 tities%0A%0A
-  @ComponentDependency%0A
   @Nonnu
@@ -969,284 +969,12 @@
 n()%0A
+
   %7B%0A
-    // This reference is immutable and the network replication%0A    // layer is responsible for managing the lifecycle of person%0A    // component and may dispose it when the Person entity is deleted%0A    // on the server which should trigger this view model being disposed.%0A
     

Move @ComponentDependency to the field as that is the latest recomendation