Fluent builder for creating ReactiveInlineVariable instances. Allows constructing reactive proxy variables by specifying getter, setter, subscribe, and unsubscribe handlers in a chainable and readable way.
// Using the builder to create a ReactiveInlineVariable
var reactiveProxy = ReactiveInlineVariable<int>
.StartBuild()
.WithGetter(() => someValue)
.WithSetter(value => someValue = value)
.WithSubscribe(handler => subscribeAction(handler))
.WithUnsubscribe(handler => unsubscribeAction(handler))
.Build();public struct Builder- Description: Fluent builder for constructing
ReactiveInlineVariable<T>instances. - See also: ReactiveInlineVariable
public Builder WithGetter(Func<T> getter)- Description: Assigns the getter function for the reactive proxy variable.
- Parameter:
getter– Function to retrieve the current value. - Returns: The same builder instance for chaining.
- Throws:
ArgumentNullExceptionifgetteris null.
public Builder WithSetter(Action<T> setter)- Description: Assigns the setter action for the reactive proxy variable.
- Parameter:
setter– Action to update the value. - Returns: The same builder instance for chaining.
- Throws:
ArgumentNullExceptionifsetteris null.
public Builder WithSubscribe(Action<Action<T>> subscribe)- Description: Assigns the subscription handler for value changes.
- Parameter:
subscribe– Action to handle subscription callbacks. - Returns: The same builder instance for chaining.
- Throws:
ArgumentNullExceptionifsubscribeis null.
public Builder WithUnsubscribe(Action<Action<T>> unsubscribe)- Description: Assigns the unsubscription handler.
- Parameter:
unsubscribe– Action to handle unsubscription callbacks. - Returns: The same builder instance for chaining.
- Throws:
ArgumentNullExceptionifunsubscribeis null.
public ReactiveInlineVariable<T> Build()- Description: Constructs and returns a new
ReactiveInlineVariable<T>instance with the provided getter, setter, subscribe, and unsubscribe handlers. - Returns: A new
ReactiveInlineVariable<T>instance. - Throws:
InvalidOperationExceptionif any of the required handlers (getter, setter, subscribe, unsubscribe) were not provided.
- Ensures that all necessary handlers are assigned before creating the reactive proxy.
- Supports fluent syntax for concise and readable code.
- Useful for integrating external properties or third-party systems into reactive architectures without duplicating state.