Show / Hide Table of Contents

Class SharedState

Holds the Shared state that all nodes of the Dependency Graph share.

Inheritance
System.Object
SharedState
Implements
ISharedState
Namespace: Cortex.Net
Assembly: Cortex.Net.dll
Syntax
public sealed class SharedState : object, ISharedState

Constructors

| Improve this Doc View Source

SharedState()

Initializes a new instance of the SharedState class.

Declaration
public SharedState()
| Improve this Doc View Source

SharedState(CortexConfiguration)

Initializes a new instance of the SharedState class.

Declaration
public SharedState(CortexConfiguration configuration)
Parameters
Type Name Description
CortexConfiguration configuration

The configuration to initialize SharedState instance with.

Properties

| Improve this Doc View Source

AllowStateChanges

Gets a value indicating whether it is allowed to change observables at this point.

Declaration
public bool AllowStateChanges { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

AllowStateReads

Gets a value indicating whether it is allowed to read observables at this point.

Declaration
public bool AllowStateReads { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

ComputationDepth

Gets or sets the computation depth.

Declaration
public int ComputationDepth { get; set; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

Configuration

Gets the configuration.

Declaration
public CortexConfiguration Configuration { get; }
Property Value
Type Description
CortexConfiguration
| Improve this Doc View Source

CurrentActionId

Gets or sets the Id of the Current Action.

Declaration
public int CurrentActionId { get; set; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

Enhancers

Gets a list of enhancers on this SharedState.

Declaration
public IList<IEnhancer> Enhancers { get; }
Property Value
Type Description
IList<IEnhancer>
| Improve this Doc View Source

GlobalState

Gets a reference to the Global Shared State or throws an exception when the Shared State is configured to not allow Shared State.

Declaration
public static ISharedState GlobalState { get; }
Property Value
Type Description
ISharedState
| Improve this Doc View Source

InBatch

Gets a value indicating whether the Dependency Graph is in Batch mode.

Declaration
public bool InBatch { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

IsRunningReactions

Gets a value indicating whether this shared state is running reactions.

Declaration
public bool IsRunningReactions { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

NextActionId

Gets or sets the Id of the Next Action.

Declaration
public int NextActionId { get; set; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

PendingReactions

Gets a queue of pending reactions.

Declaration
public Queue<Reaction> PendingReactions { get; }
Property Value
Type Description
Queue<Reaction>
| Improve this Doc View Source

PendingUnobservations

Gets a queue of all pending Unobservations.

Declaration
public Queue<IObservable> PendingUnobservations { get; }
Property Value
Type Description
Queue<IObservable>
| Improve this Doc View Source

ReactionScheduler

Gets or sets the Scheduler function. The Scheduler function can call it's inner action to run the default reaction algorithm in Cortex.NET.

Declaration
public Action<Action> ReactionScheduler { get; set; }
Property Value
Type Description
Action<Action>
| Improve this Doc View Source

RunId

Gets the shared derivation RunId counter.

Declaration
public int RunId { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

ShouldInvoke

Gets a value indicating whether the action should be invoked on the original thread that created the context.

Declaration
public bool ShouldInvoke { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

SuppressReactionErrors

Gets or sets a value indicating whether to suppress reaction errors. Suppressing happens when an action is the root cause of reactions to fail further because of the incorrect state.

Declaration
public bool SuppressReactionErrors { get; set; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

TrackingDerivation

Gets the IDerivation instance that the shared state is currently tracking.

Declaration
public IDerivation TrackingDerivation { get; }
Property Value
Type Description
IDerivation

Methods

| Improve this Doc View Source

CreateAtom(String, Action, Action)

Creates a new Atom that references this shared Storage.

Declaration
public IAtom CreateAtom(string name = null, Action onBecomeObserved = null, Action onBecomeUnobserved = null)
Parameters
Type Name Description
System.String name

The name for this Atom. A unique name will be generated in case a name is not provided.

Action onBecomeObserved

An that will be executed when the Atom changes from unobserved to observed.

Action onBecomeUnobserved

An that will be executed when the Atom changes from observed to unobserved.

Returns
Type Description
IAtom

A new instance that implements IAtom.

| Improve this Doc View Source

EndAllowStateChanges(Boolean)

End of a section where AllowStateChanges is modified.

Declaration
public void EndAllowStateChanges(bool previousAllowStateChanges)
Parameters
Type Name Description
System.Boolean previousAllowStateChanges

The previous value to restore.

| Improve this Doc View Source

EndAllowStateReads(Boolean)

End of a section where allowedStateReads is modified.

Declaration
public void EndAllowStateReads(bool previousAllowStateReads)
Parameters
Type Name Description
System.Boolean previousAllowStateReads

The previous value to restore.

| Improve this Doc View Source

EndBatch()

Ends a Batch.

Declaration
public void EndBatch()
Remarks

This method can be called multiple times but should always be balanced with an equal amount of StartBatch() calls.

| Improve this Doc View Source

EndTracking(IDerivation)

Ends tracking the current IDerivation instance and restores the previous derivation.

Declaration
public void EndTracking(IDerivation previousDerivation)
Parameters
Type Name Description
IDerivation previousDerivation

The previous derivation.

| Improve this Doc View Source

GetUniqueId()

Gets a unique Id that is incremented every time and identifies unique instances.

Declaration
public int GetUniqueId()
Returns
Type Description
System.Int32

The new unique Id.

| Improve this Doc View Source

IncrementRunId()

Increments the RunId and returns the new value.

Declaration
public int IncrementRunId()
Returns
Type Description
System.Int32

The new RunId.

| Improve this Doc View Source

OnSpy(Object, SpyEventArgs)

Triggers the Spy event handler with the specified event args.

Declaration
public void OnSpy(object sender, SpyEventArgs spyEventArgs)
Parameters
Type Name Description
System.Object sender

The sender of the event.

SpyEventArgs spyEventArgs

The event arguments for the spy event.

| Improve this Doc View Source

OnUnhandledReactionException(Reaction, UnhandledExceptionEventArgs)

Fires the UnhandledReactionException event.

Declaration
public void OnUnhandledReactionException(Reaction reaction, UnhandledExceptionEventArgs unhandledExceptionEventArgs)
Parameters
Type Name Description
Reaction reaction

The reaction that caused the unhandled exception.

UnhandledExceptionEventArgs unhandledExceptionEventArgs

The event arguments for the exception.

| Improve this Doc View Source

ResolveState(ISharedState)

Resolves a shared state for Weaved objects.

Declaration
public static ISharedState ResolveState(ISharedState sharedState)
Parameters
Type Name Description
ISharedState sharedState

The shared state.

Returns
Type Description
ISharedState

Shared state when found, otherwise throws an exception.

| Improve this Doc View Source

RunReactions()

Runs reactions. This implementation will run the default Reaction Scheduler function.

Declaration
public void RunReactions()
| Improve this Doc View Source

SetAsyncLocalState(ISharedState)

Set the AsyncLocalSharedState.

Declaration
public static void SetAsyncLocalState(ISharedState sharedState)
Parameters
Type Name Description
ISharedState sharedState

The Async Local Shared State.

| Improve this Doc View Source

StartAllowStateChanges(Boolean)

Start of a section where AllowStateChanges is modified.

Declaration
public bool StartAllowStateChanges(bool allowStateChanges)
Parameters
Type Name Description
System.Boolean allowStateChanges

Whether to allow State changes.

Returns
Type Description
System.Boolean

The previous value.

| Improve this Doc View Source

StartAllowStateReads(Boolean)

Start of a section where allowedStateReads is modified.

Declaration
public bool StartAllowStateReads(bool allowStateReads)
Parameters
Type Name Description
System.Boolean allowStateReads

Whether to allow State reads.

Returns
Type Description
System.Boolean

The previous value.

| Improve this Doc View Source

StartBatch()

Starts a Batch.

Declaration
public void StartBatch()
Remarks

This method can be called multiple times but should always be balanced with an equal amount of EndBatch() calls.

| Improve this Doc View Source

StartTracking(IDerivation)

Starts tracking the IDerivation instance given as paramteter.

Declaration
public IDerivation StartTracking(IDerivation derivation)
Parameters
Type Name Description
IDerivation derivation

The derivation to track.

Returns
Type Description
IDerivation

The prevous derivation.

| Improve this Doc View Source

StartUntracked()

Starts an untracked part of a derviation.

Declaration
public IDerivation StartUntracked()
Returns
Type Description
IDerivation

The current derivation to restore later.

Events

| Improve this Doc View Source

SpyEvent

Spy event that fires when any observable attached to this Shared State reports a significant change. Can be used to implement a state inspection tool or something like react-dev-tools.

Declaration
public event EventHandler<SpyEventArgs> SpyEvent
Event Type
Type Description
EventHandler<SpyEventArgs>
| Improve this Doc View Source

UnhandledReactionException

Event that fires when a reaction produces an unhandled exception.

Declaration
public event EventHandler<UnhandledExceptionEventArgs> UnhandledReactionException
Event Type
Type Description
EventHandler<UnhandledExceptionEventArgs>

Implements

ISharedState

Extension Methods

TraceExtensions.Trace<TObject, TMember>(TObject, Expression<Func<TObject, TMember>>, TraceMode)
ReactiveObjectTypeUtilExtensions.GetObservable(Object)
ReactiveObjectTypeUtilExtensions.GetObservable<TObject, TMember>(TObject, Expression<Func<TObject, TMember>>)
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX