Class ComputedValue<T>
A node in the state dependency root that observes other nodes, and can be observed itself.
Inheritance
Implements
Namespace: Cortex.Net.Core
Assembly: Cortex.Net.dll
Syntax
public class ComputedValue<T> : object, IObservable, IDerivation, IDependencyNode, IComputedValue<T>, IComputedValue, IValue<T>, IValueType Parameters
| Name | Description | 
|---|---|
| T | The type of the computed value. | 
Properties
| Improve this Doc View SourceDependenciesState
Gets or sets the state of the dependencies of this IDerivation instance.
Declaration
public DerivationState DependenciesState { get; set; }Property Value
| Type | Description | 
|---|---|
| DerivationState | 
IsBeingObserved
Gets or sets a value indicating whether the observable is being observed. An observable is being observed when at least one derivation actually accesses its value.
Declaration
public bool IsBeingObserved { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
IsPendingUnobservation
Gets or sets a value indicating whether this atom is pending Unobservation.
Declaration
public bool IsPendingUnobservation { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
IsTracing
Gets or sets the trace mode of this Derivation.
Declaration
public TraceMode IsTracing { get; set; }Property Value
| Type | Description | 
|---|---|
| TraceMode | 
LastAccessedBy
Gets or sets the Id of the derivation run that last accessed this observable. If this Id equals the RunId of the current derivation the dependency is already established.
Declaration
public int LastAccessedBy { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Int32 | 
LowestObserverState
Gets or sets the lowest DerivationState on any of it's observers.
Declaration
public DerivationState LowestObserverState { get; set; }Property Value
| Type | Description | 
|---|---|
| DerivationState | 
Name
Gets the Name of the Atom instance.
Declaration
public string Name { get; }Property Value
| Type | Description | 
|---|---|
| System.String | 
NewObserving
Gets a set of IObservable instances that have been hit during a new derivation run.
Declaration
public ISet<IObservable> NewObserving { get; }Property Value
| Type | Description | 
|---|---|
| ISet<IObservable> | 
Observers
Gets the Observers.
Declaration
public ISet<IDerivation> Observers { get; }Property Value
| Type | Description | 
|---|---|
| ISet<IDerivation> | 
Observing
Gets a set of IObservable instances that are currently observed.
Declaration
public ISet<IObservable> Observing { get; }Property Value
| Type | Description | 
|---|---|
| ISet<IObservable> | 
RequiresObservable
Gets a value indicating whether to warn if this derivation is required to visit at least one observable.
Declaration
public bool RequiresObservable { get; }Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
RunId
Gets or sets the id of the current run of a derivation. Each time the derivation is tracked this number is increased by one. This number is unique within the current shared state.
Declaration
public int RunId { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Int32 | 
SharedState
Gets the Shared State of all the nodes in the dependency graph.
Declaration
public ISharedState SharedState { get; }Property Value
| Type | Description | 
|---|---|
| ISharedState | 
Value
Gets or sets the underlying value.
Declaration
public T Value { get; set; }Property Value
| Type | Description | 
|---|---|
| T | 
Methods
| Improve this Doc View SourceObserve(EventHandler<ValueChangedEventArgs<T>>, Boolean)
Registers the secified event handler, and optionally fires it first.
Declaration
public IDisposable Observe(EventHandler<ValueChangedEventArgs<T>> changedEventHandler, bool fireImmediately)Parameters
| Type | Name | Description | 
|---|---|---|
| EventHandler<ValueChangedEventArgs<T>> | changedEventHandler | The event handler to register. | 
| System.Boolean | fireImmediately | Whether to fire the event handler immediately. | 
Returns
| Type | Description | 
|---|---|
| IDisposable | A disposable to remove the event handler when the disposable is disposed. | 
OnBecomeObserved()
Method that triggers event BecomeObserved.
Declaration
public void OnBecomeObserved()OnBecomeStale()
Propagates confirmation of a possible change to all observers of this ComputedValue<T> for delayed computation.
Declaration
public void OnBecomeStale()OnBecomeUnobserved()
Method that triggers event BecomeUnobserved.
Declaration
public void OnBecomeUnobserved()Suspend()
Suspends computation of this computed value when the last observer leaves. Computed values are automatically teared down when the last observer leaves. This process happens recursively, this computed might be the last observabe of another, etc.
Declaration
public void Suspend()Events
| Improve this Doc View SourceBecomeObserved
Event that will fire after the Atom has become observed.
Declaration
public event EventHandler BecomeObservedEvent Type
| Type | Description | 
|---|---|
| EventHandler | 
BecomeUnobserved
Event that will fire after the observable has become unobserved.
Declaration
public event EventHandler BecomeUnobservedEvent Type
| Type | Description | 
|---|---|
| EventHandler | 
Changed
Event that fires after the value has changed.
Declaration
public event EventHandler<ValueChangedEventArgs<T>> ChangedEvent Type
| Type | Description | 
|---|---|
| EventHandler<ValueChangedEventArgs<T>> | 
Explicit Interface Implementations
| Improve this Doc View SourceIValue.Value
Gets or sets the value. Explicit implementation of Value.
Declaration
object IValue.Value { get; set; }Returns
| Type | Description | 
|---|---|
| System.Object |