Class SharedStateObservableExtensions
Extension methods for ISharedState to make attach an object to a shared state and make sure that Enhancer methods are properly followed.
Inheritance
Namespace: Cortex.Net.Api
Assembly: Cortex.Net.dll
Syntax
public static class SharedStateObservableExtensions : object
Methods
| Improve this Doc View SourceBox<T>(ISharedState, T, String, IEnhancer)
Boxes the value T inside an IObservableValue<T> instance.
Declaration
public static IObservableValue<T> Box<T>(this ISharedState sharedState, T initialValue, string name = null, IEnhancer enhancer = null)
Parameters
Type | Name | Description |
---|---|---|
ISharedState | sharedState | The shared state to operate on. |
T | initialValue | The initial value to use. |
System.String | name | The name of the observable value. |
IEnhancer | enhancer | The optional enhancer to use. default enhancer is the referenceEnhancer. |
Returns
Type | Description |
---|---|
IObservableValue<T> | The observable. |
Type Parameters
Name | Description |
---|---|
T | The type to box. |
Collection<T>(ISharedState, IEnumerable<T>, String, IEnhancer)
Creates an observable Collection from an IEnumerable.
Declaration
public static ICollection<T> Collection<T>(this ISharedState sharedState, IEnumerable<T> initialValues = null, string name = null, IEnhancer enhancer = null)
Parameters
Type | Name | Description |
---|---|---|
ISharedState | sharedState | The shared state to operate on. |
IEnumerable<T> | initialValues | The initial values to use. |
System.String | name | The name of the observable collection. |
IEnhancer | enhancer | The optional enhancer to use. default enhancer is the deep enhancer. |
Returns
Type | Description |
---|---|
ICollection<T> | The observable. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements. |
Computed<T>(ISharedState, Func<T>, String)
Creates a computed value.
Declaration
public static IComputedValue<T> Computed<T>(this ISharedState sharedState, Func<T> getter, string name = null)
Parameters
Type | Name | Description |
---|---|---|
ISharedState | sharedState | The shared state to operate on. |
Func<T> | getter | The getter function to use. |
System.String | name | The name of the observable collection. |
Returns
Type | Description |
---|---|
IComputedValue<T> | The computed value. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements. |
Dictionary<TKey, TValue>(ISharedState, IDictionary<TKey, TValue>, String, IEnhancer)
Creates an observable Dictionary from an initial dictionary.
Declaration
public static IDictionary<TKey, TValue> Dictionary<TKey, TValue>(this ISharedState sharedState, IDictionary<TKey, TValue> initialValues = null, string name = null, IEnhancer enhancer = null)
Parameters
Type | Name | Description |
---|---|---|
ISharedState | sharedState | The shared state to operate on. |
IDictionary<TKey, TValue> | initialValues | The initial values to use. |
System.String | name | The name of the observable collection. |
IEnhancer | enhancer | The optional enhancer to use. default enhancer is the deep enhancer. |
Returns
Type | Description |
---|---|
IDictionary<TKey, TValue> | The observable. |
Type Parameters
Name | Description |
---|---|
TKey | The type of the key. |
TValue | The type of the value. |
Observable<T>(ISharedState, Func<T>)
Makes sure that the observable is initialized against the shared state and any other objects along the tree.
Declaration
public static T Observable<T>(this ISharedState sharedState, Func<T> initializerFunction)
Parameters
Type | Name | Description |
---|---|---|
ISharedState | sharedState | The shared state to attach to. |
Func<T> | initializerFunction | The initializer function. |
Returns
Type | Description |
---|---|
T | The observable you wannt. |
Type Parameters
Name | Description |
---|---|
T | The type to return. |
Set<T>(ISharedState, IEnumerable<T>, String, IEnhancer)
Creates an observable Set from an initial Ienumberable.
Declaration
public static ISet<T> Set<T>(this ISharedState sharedState, IEnumerable<T> initialValues = null, string name = null, IEnhancer enhancer = null)
Parameters
Type | Name | Description |
---|---|---|
ISharedState | sharedState | The shared state to operate on. |
IEnumerable<T> | initialValues | The initial values to use. |
System.String | name | The name of the observable collection. |
IEnhancer | enhancer | The optional enhancer to use. default enhancer is the deep enhancer. |
Returns
Type | Description |
---|---|
ISet<T> | The observable. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements. |