Download Latest Version v2.0.0.tar.gz (10.8 MB)
Email in envelope

Get an email when there's a new version of Material Motion

Home / v1.2.0
Name Modified Size InfoDownloads / Week
Parent folder
README.md 2017-04-12 2.7 kB
v1.2.0.tar.gz 2017-04-12 10.1 MB
v1.2.0.zip 2017-04-12 10.2 MB
Totals: 3 Items   20.3 MB 0

This minor release introduces a new operator, startWith, which is meant to replace the initialValue operator.

New features

startWith operator

The new startWith operator replaces initialValue and behaves slightly differently: startWith returns a memory stream, which is a stream that stores the last value it received and emits it upon subscription. What this means is that the provided initial value will only be emitted once, ever, and that the resulting stream is guaranteed to emit a value on subscription.

You can use startWith to take a stream that may not initially emit values (like a gesture stream) and prime it with an initial value. For example, we use startWith in the "How to use reactive constraints" example in order to ensure that our axis line property is primed with a value.

:::swift
let axisCenterX = runtime.get(axisLine.layer).position.x()
runtime.add(Draggable(), to: exampleView) { $0
  .startWith(exampleView.layer.position)
  .xLocked(to: axisCenterX)
}
runtime.add(Draggable(), to: axisLine) { $0.yLocked(to: axisLine.layer.position.y) }

New deprecations

  • initialValue(_:) has been deprecated in favor of the new startWith(_:) operator.

Source changes

API changes

Auto-generated by running:

apidiff origin/stable release-candidate swift MaterialMotion.xcworkspace MaterialMotion

MotionObservableConvertible

new method: startWith(_:) in MotionObservableConvertible

deprecated method: initialValue(_:) in MotionObservableConvertible: Use startWith(_:) instead.

Non-source changes

Source: README.md, updated 2017-04-12