Class ComputedAttribute
Attribute that signals that the property or method it is applied to, should be interpreted as a computed value.
Inheritance
Namespace: Cortex.Net.Api
Assembly: Cortex.Net.dll
Syntax
public class ComputedAttribute : Attribute
Constructors
| Improve this Doc View SourceComputedAttribute(Boolean, Boolean)
Initializes a new instance of the ComputedAttribute class.
Declaration
public ComputedAttribute(bool requiresReaction = false, bool keepAlive = false)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | requiresReaction | Whether the computed has to be calculated inside a reactive context. |
System.Boolean | keepAlive | whether to keep the computed value alive when it's not observed. |
ComputedAttribute(String, Boolean, Boolean)
Initializes a new instance of the ComputedAttribute class.
Declaration
public ComputedAttribute(string name, bool requiresReaction = false, bool keepAlive = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the computed value. |
System.Boolean | requiresReaction | Whether the computed has to be calculated inside a reactive context. |
System.Boolean | keepAlive | whether to keep the computed value alive when it's not observed. |
ComputedAttribute(String, Type, Boolean, Boolean)
Initializes a new instance of the ComputedAttribute class.
Declaration
public ComputedAttribute(string name, Type equalityComparerType, bool requiresReaction = false, bool keepAlive = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the computed value. |
Type | equalityComparerType | The type of the comparer used to see whether the value has changed. |
System.Boolean | requiresReaction | Whether the computed has to be calculated inside a reactive context. |
System.Boolean | keepAlive | whether to keep the computed value alive when it's not observed. |
ComputedAttribute(Type, Boolean, Boolean)
Initializes a new instance of the ComputedAttribute class.
Declaration
public ComputedAttribute(Type equalityComparerType, bool requiresReaction = false, bool keepAlive = false)
Parameters
Type | Name | Description |
---|---|---|
Type | equalityComparerType | The type of the comparer used to see whether the value has changed. |
System.Boolean | requiresReaction | Whether the computed has to be calculated inside a reactive context. |
System.Boolean | keepAlive | whether to keep the computed value alive when it's not observed. |
Properties
| Improve this Doc View SourceEqualityComparerType
Gets the type of the comparer used for equality.
Declaration
public Type EqualityComparerType { get; }
Property Value
Type | Description |
---|---|
Type |
KeepAlive
Gets a value indicating whether to keep this computed value alive if it is not observed by anybody. Be aware, this can easily lead to memory leaks as it will result in every observable used by this computed value, keeping the computed value in memory.
Declaration
public bool KeepAlive { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Name
Gets the Name of the action.
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
System.String |
RequiresReaction
Gets a value indicating whether a reactive context is required. it is recommended to set this one to true on very expensive computed values. If you try to read it's value, but the value is not being tracked by some observe, it will cause the computed to throw, instead of doing an expensive re-evalution.
Declaration
public bool RequiresReaction { get; }
Property Value
Type | Description |
---|---|
System.Boolean |