material-motion-swift icon indicating copy to clipboard operation
material-motion-swift copied to clipboard

Add support for tracing data moving down a stream

Open jverkoey opened this issue 8 years ago • 1 comments
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()

jverkoey avatar Mar 10 '17 21:03 jverkoey

Explored an approach that seems decently promising. In short:

  1. add a Tracer type with a func trace(Metadata, value) method.
  2. Allow a MotionObserver to store an Tracer instance.
  3. Subscriptions should pass along the Tracer instance, if available.
  4. 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.

jverkoey avatar Mar 11 '17 19:03 jverkoey