Skip to content
This repository has been archived by the owner on Aug 13, 2021. It is now read-only.

v1.2.0

Compare
Choose a tag to compare
@jverkoey jverkoey released this 12 Apr 18:33
· 96 commits to stable since this release

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.

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