v1.2.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.
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 newstartWith(_:)
operator.
Source changes
- Deprecate initialValue and provide startWith as a replacement. (Jeff Verkoeyen)
- Renamed normalized.swift to normalizedBy.swift. (Jeff Verkoeyen)
- Rename unit test file rewriteTo.swift to rewriteToTests.swift. (Jeff Verkoeyen)
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
- Fix README example. (Jeff Verkoeyen)
- Fix typo. (Jeff Verkoeyen)