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
runtime MotionRuntime.get
Status Interface level Implementation level Library
Proposed as of April 17, 2017 L1: App creator L4: Runtime engineering material-motion
UpdatesCurrent StatusInitiation dateCompletion date
Introduced proposal. Stable April 17, 2017
platformsrctests
iOS (Swift) View

MotionRuntime.get specification

This is the engineering specification for the MotionRuntime’s get API.

Overview

Reactive properties are often a representation of existing information in an application. For a given element, we might have a reactive property representation of its position, opacity, and background color.

Our goal is to ensure that element reactive properties are easy to access and reuse in order to reduce the likelihood of multiple reactive properties existing for the same element’s information.

This spec proposes an API, runtime.get(object), by which a reactive instance of an object can be returned. A reactive instance is a representation of an object where all properties are cached reactive property instances.

let reactiveView = runtime.get(view)

// Changing the reactive property
reactiveView.position.value = .init(x: 50, y: 100)

// Connecting one view's position to another
runtime.connect(reactiveView.position, to: runtime.get(otherView).position)

MVP

Expose a get API

Accept an object and return a reactive version of that object. This will require building reactive variants of supported types.

class MotionRuntime {
  public func get(view: UIView) -> ReactiveUIView
}

Always return the same reactive instance for a given object

Cache and return the same reactive instance.