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 MotionRuntime MotionRuntime-addInteraction · MotionRuntime-get · MotionRuntime-interactions · MotionRuntime-toGraphViz · MotionRuntime-toggle · MotionRuntime-visualizationElement · MotionRuntime-whenAllAtRest · interactions
Status Interface level Implementation level Library
Stable as of February 20, 2017 L1: App creator L4: Runtime engineering material-motion
UpdatesCurrent StatusInitiation dateCompletion date
runtime.add for streams changed to runtime.connect Stable March 23, 2017
platformsrctests
Android View
JavaScript View
iOS (Swift) View

MotionRuntime specification

This is the engineering specification for the MotionRuntime object.

Overview

A MotionRuntime’s primary responsibility is to write the output of streams to reactive properties.

We use the terms motion runtime and runtime interchangeably throughout the starmap.

MVP

Expose a concrete MotionRuntime class

public class MotionRuntime {
}

Expose a connect API

The implementation should subscribe to the stream and hold on to its subscription internally.

New values received from the subscribed stream should be written to the property.

class MotionRuntime {
  public func connect<T>(stream: MotionObservable<T>, to property: ReactiveProperty<T>)
}

Create private storage for subscriptions

An array is adequate because we currently have no mechanism for removing subscriptions once they are made.

class MotionRuntime {
  private var subscriptions: [Subscription] = []
}

Store all subscriptions

An array is adequate because we currently have no mechanism for removing subscriptions once they are made.

class MotionRuntime {
  func connect<T>(stream: MotionObservable<T>, to property: ReactiveProperty<T>) {
    subscriptions.append(stream.subscribe(next: { property.value = $0 }))
  }
}