_nextOperator specification
This is the engineering specification for the MotionObservable
operator: _nextOperator
.
Overview
_nextOperator
is a means by which new operators can be created. An operator can change, add, or
remove values in the stream. An operator can also change the type of emitted values.
MVP
Expose _nextOperator API
operation
should be a function that receives two arguments: the value T
from upstream and a callback that dispatches a value on the next
channel. It will be called every time a new T
is received from upstream.
class MotionObservable<T> {
public func _nextOperator<U>(operation: (T, (U) -> Void) -> Void) -> MotionObservable<U>
Pass next to the operation function
The operation should only be allowed to invoke next
. Pass the observer’s next function to the
operation.
class MotionObservable<T> {
public func _nextOperator<U>(operation: (T, (U) -> Void) -> Void) -> MotionObservable<U>
return MotionObservable<U> { observer in
let subscription = self.subscribe(next: { value in
operation(value, observer.next)
}
return {
subscription.unsubscribe()
}
}
}
}