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
$._nextOperator _map
$._filter
anchorPointAdjustment · centroid · distanceFrom · inverted · lowerBound · normalizedBy · offsetBy · pluck · rewriteRange · rewriteTo · rubberBanded · scaledBy · toString · upperBound · velocity · x · xLockedTo · y · yLockedTo
Status Interface level Implementation level Library
Stable as of December 13, 2016 L3: Stream creator L4: Runtime engineering material-motion
platformsrctests
Android View View
iOS (Swift) View View
JavaScript View View
_map
upstream (T)
(U) downstream

_map specification

This is the engineering specification for the MotionObservable operator: _map.

Overview

_map transforms an incoming value of type T to a new value of type U. ReactiveX documentation.

Example usage

stream._map { point in
  return point.x
}

upstream          |  downstream
{ x: 10, y: 10 }  |  10
{ x: 50, y: 10 }  |  50
{ x: 75, y: 50 }  |  75

MVP

Expose _map API

Should delegate to _nextOperator.

class MotionObservable<T> {

  public func _map<U>(transform: (T) -> U) -> MotionObservable<U> {
    return _nextOperator { value, next in
      next(transform(value))
    }
  }