Proxies
IRP使()IRPGet*
The first aspect of IRP is in its ability to enable composition of intent by using proxies to artifacts. One can view these proxies are holders of identifiers (enabling service-side binding steps) and builders for expressions that represent the intent. Concretely, this gets reflected in the Get* methods on an IRP context, for example:
IAsyncReactiveQbservable<T> GetObservable<T>(Uri observableId);
IAsyncReactiveQbserver<T> GetObserver<T>(Uri observerId);
IAsyncReactiveQubscription GetSubscription(Uri subscriptionId);
ExpressionGet*NameParameterExpression
When accessing the Expression property on a proxy, one will find a ParameterExpression whose Name refers to the identifier of the artifact that was passed to the Get* method.
使
Applying query operators results in the creation of bigger expression trees that compose the expressions of the operators operands, which subsequently get encapsulated in an object that can be used for further composition:
var numbers = ctx.GetObservable<int>(new Uri("eg://numbers"));
// numbers.Expression
// ~ Expression.Parameter("eg://numbers")
var positive = numbers.Where(x => x >= 0);
// positive.Expression
// ~ Expression.Call(
// Where,
// Expression.Parameter("eg://numbers"),
// Expression.Lambda(...)
// )
var negative = positive.Select(x => -x);
// negative.Expression
// ~ Expression.Call(
// Select,
// Expression.Call(
// Where,
// Expression.Parameter("eg://numbers"),
// Expression.Lambda(...)
// ),
// Expression.Lambda(...)
// )
DDL使
Its important to realize that composition of artifacts happens entirely in-memory and never communicates with a service. After composing the intent, it can be used to perform a DDL operation such as the creation of a hot artifact (e.g. a subscription or stream) or the definition of a cold artifact (e.g. a parameterized observable or observer). For example:
await negative.SubscribeAsync(new Uri("eg://sub/neg"), ...);