material-motion-swift
material-motion-swift copied to clipboard
Add support for tracing data moving down a stream
trafficstars
Unclear what this API would look like, but ideally there'd be some way to turn:
let someStream = gesture.translation().xLocked(to: 20)
into
gesture => { ... } => translation() => {50, 20} => xLocked(to: 50) => {20, 20}
or something similar. This would be emitted in real time to the console.
Some possible approaches:
- Create an operator that traces anything upstream of it. E.g.
gesture.translation().xLocked(to: 20).trace()
Explored an approach that seems decently promising. In short:
- add a Tracer type with a
func trace(Metadata, value)method. - Allow a MotionObserver to store an Tracer instance.
- Subscriptions should pass along the Tracer instance, if available.
- Connectors should invoke observer.trace and then observer.next.
This allows each subscription to be output in a line-by-line fashion. Supporting the structured variant as shown above is likely possible by inspecting the metadata object for parent information. If there is parent information, then we write the new information on a new line with an indent.