MimiProcessingParameter
public protocol MimiProcessingParameter<Value> : AnyObject
Protocol for a processing parameter.
MimiProcessingParameter represents a parameter in Mimi Processing, providing publishers for value and state changes, and methods for applying and loading values.
-
Name of the parameter.
Declaration
Swift
var name: String { get } -
A publisher for tracking value changes related to the
MimiProcessingParameter.Declaration
Swift
var valuePublisher: AnyPublisher<Value, Never> { get } -
Current value of the parameter.
Declaration
Swift
var value: Value { get } -
A publisher for tracking state changes related to the
MimiProcessingParameter.This publisher emits values of type
MimiProcessingParameterUpdateStateto notify subscribers about changes.Note
The publisher never produces errors (Never), making it suitable for representing a continuous stream of application state updates without failure.Example usage:
// Subscribe to changes of the value application state let subscription = processingInstance.updateState .sink { state in print("Processing parameter update state: \(state)") }Declaration
Swift
var updateState: AnyPublisher<MimiProcessingParameterUpdateState<Value>, Never> { get } -
The data source for the parameter, if available.
Declaration
Swift
var dataSource: AnyMimiProcessingParameterDataSource<Value>? { get } -
Synchronize the applicator with the current parameter value.
This function attempts to force update the associated
MimiProcessingParameterApplicatorinstance with the current value of theMimiProcessingParameter.Declaration
Swift
func synchronizeApplicator() async throws -
Apply a new value to the parameter.
This will attempt to apply the provided value on the associated applicator if it is out of date. For the application to succeed,
successmust be reported by the applicator. If the applicator fails to report success, the application fails, and an error is thrown.Applications are serialised per parameter: a call made while another
apply(_:),load()orsynchronizeApplicator()is in flight waits for it to finish, and the applicator is never invoked concurrently for the same parameter. A call made while the task is cancelled throwsCancellationError.If the calling task is cancelled while the applicator is already running, the call throws
CancellationErrorat once and the applicator’s task is cancelled, but the applicator is not waited for.updateStatethen stays.applyinguntil the applicator returns, and reports.applied, aftervaluehas been updated, or.failedwith the applicator’s error. If anotherapply(_:),load()orsynchronizeApplicator()has started on the parameter by then, the state it reported is left alone and onlyvalueis updated, provided the applicator still holds that value.valueandupdateStatecan therefore change after the call has thrown. With an applicator that never returns,updateStatestays.applyinguntil the next operation on the parameter.An application that exceeds the applicator’s timeout is followed up in the same way, except that the call throws
applyTimeoutExceededandupdateStatereports.failedwith that error at once. If the applicator returns successfully afterwards,valueis updated andupdateStatereports.applied, under the same conditions as above; if it throws, the reported timeout stands.Warning
These calls are not reentrant. An applicator or data source must not call
apply(_:),load()orsynchronizeApplicator()on the parameter it is serving and wait for the result: that call waits for the operation that is already in flight and never completes.Declaration
Swift
func apply(_ value: Value) async throwsParameters
valueValue to apply.
-
Load the parameter value from its data source and attempt to apply it.
This function will attempt to load a new parameter value from a data source if available and then apply it on all registered applicators Effectively this will
load()and thenapply()the value.Loads are serialised with applications: a call made while another
load()orapply(_:)is in flight waits for it to finish before loading. If the loaded value is already applied by then, the applicator is not invoked again.Declaration
Swift
func load() async throws
MimiProcessingParameter Protocol Reference