Material Motion Exploring solutions that will empower creators with the tools needed to describe and implement rich, interactive motion on any platform. Edit this page · History
MotionObservable Object connection type
Status Interface level Implementation level Library
Stable as of March 2, 2017 L2: Interaction creator L4: Runtime engineering material-motion

Object connection specification

This is the engineering specification for an object MotionObservable connection implementation.

MVP

Return a motion observable

return MotionObservable { observer in
  // Connect to a source
  return {
    // Disconnect from the source
  }
}

Define a Connection object

Is a private class that represents a single connection.

private final class SomeConnection {

Connection is initialized with the observer and any state information

Both values must be stored by the connection.

class SomeConnection {
  init(state: SomeState, observer: MotionObserver<T>)

Add self as an observer

This should be done at the time of construction.

class SomeConnection {
  init(state: SomeState, observer: MotionObserver<T>) {
    ...
    state.addTarget(self, action: #selector(event))

Propagate events to the observer

Propagate the gesture when the gesture event callback is invoked.

class SomeConnection {
  private func event(data: Data) {
    propagate(data)
  }