MotionRuntime specification
This is the engineering specification for the MotionRuntime
object.
Overview
A MotionRuntime
’s primary responsibility is to write the output of streams to reactive properties.
We use the terms motion runtime and runtime interchangeably throughout the starmap.
MVP
Expose a concrete MotionRuntime class
public class MotionRuntime {
}
Expose a connect API
The implementation should subscribe to the stream and hold on to its subscription internally.
New values received from the subscribed stream should be written to the property.
class MotionRuntime {
public func connect<T>(stream: MotionObservable<T>, to property: ReactiveProperty<T>)
}
Create private storage for subscriptions
An array is adequate because we currently have no mechanism for removing subscriptions once they are made.
class MotionRuntime {
private var subscriptions: [Subscription] = []
}
Store all subscriptions
An array is adequate because we currently have no mechanism for removing subscriptions once they are made.
class MotionRuntime {
func connect<T>(stream: MotionObservable<T>, to property: ReactiveProperty<T>) {
subscriptions.append(stream.subscribe(next: { property.value = $0 }))
}
}