threshold specification
This is the engineering specification for the MotionObservable
operator: threshold
.
Overview
threshold
emits a ThresholdEvent based on the incoming value’s position around a threshold.
Example usage
stream.threshold(50)
upstream position | downstream
20 50 | .below
50 50 | .within
60 50 | .above
MVP
Expose a ThresholdSide enum type
public enum ThresholdSide {
case below
case within
case above
}
Expose a threshold operator API
Use _nextOperator
to implement the operator. Accept a single position value.
class MotionObservable<number> {
public func threshold<U>(_ threshold: number) -> MotionObservable<ThresholdSide>