Class SharedStateReactionExtensions
Extension methods that deal with Reactions on an ISharedState instance.
Inheritance
Namespace: Cortex.Net.Api
Assembly: Cortex.Net.dll
Syntax
public static class SharedStateReactionExtensions : object
Methods
| Improve this Doc View SourceAutorun(ISharedState, Action<Reaction>, AutorunOptions)
Creates a new Autorun reaction.
Declaration
public static IDisposable Autorun(this ISharedState sharedState, Action<Reaction> expression, AutorunOptions autorunOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ISharedState | sharedState | The shared state to operate on. |
| Action<Reaction> | expression | The expression that should autorun. |
| AutorunOptions | autorunOptions | An AutorunOptions instance with options. |
Returns
| Type | Description |
|---|---|
| IDisposable | An |
Reaction<T>(ISharedState, Func<Reaction, T>, Action<T, Reaction>, ReactionOptions<T>)
Creates a reaction that operates on data of type T.
Declaration
public static IDisposable Reaction<T>(this ISharedState sharedState, Func<Reaction, T> expression, Action<T, Reaction> effect, ReactionOptions<T> reactionOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ISharedState | sharedState | The shared state to use. |
| Func<Reaction, T> | expression | The expression that delivers a value. |
| Action<T, Reaction> | effect | The effect that is executed when the value changes. |
| ReactionOptions<T> | reactionOptions | The options to use for the reaction. |
Returns
| Type | Description |
|---|---|
| IDisposable | An |
Type Parameters
| Name | Description |
|---|---|
| T | The type the reaction operates on. |
Reaction<T>(ISharedState, Func<Reaction, T>, Func<T, Reaction, Task>, ReactionOptions<T>)
Creates a reaction that operates on data of type T.
Declaration
public static IDisposable Reaction<T>(this ISharedState sharedState, Func<Reaction, T> expression, Func<T, Reaction, Task> effect, ReactionOptions<T> reactionOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ISharedState | sharedState | The shared state to use. |
| Func<Reaction, T> | expression | The expression that delivers a value. |
| Func<T, Reaction, Task> | effect | The effect that is executed when the value changes. |
| ReactionOptions<T> | reactionOptions | The options to use for the reaction. |
Returns
| Type | Description |
|---|---|
| IDisposable | An |
Type Parameters
| Name | Description |
|---|---|
| T | The type the reaction operates on. |
Remarks
Only pass asynchronous effect functions that wrap state modifications in actions.