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

Commit 959ecd2

Browse files
author
Jeff Verkoeyen
committed
Merge branch 'release-candidate' into stable
2 parents e7f3825 + 6565de5 commit 959ecd2

File tree

14 files changed

+177
-59
lines changed

14 files changed

+177
-59
lines changed

.jazzy.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
module: MaterialMotion
2-
module_version: 1.1.0
2+
module_version: 1.2.0
33
sdk: iphonesimulator
44
xcodebuild_arguments:
55
- -workspace
66
- MaterialMotion.xcworkspace
77
- -scheme
88
- MaterialMotion
99
github_url: https://github.com/material-motion/material-motion-swift
10-
github_file_prefix: https://github.com/material-motion/material-motion-swift/tree/v1.1.0
10+
github_file_prefix: https://github.com/material-motion/material-motion-swift/tree/v1.2.0

CHANGELOG.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,53 @@
1+
# 1.2.0
2+
3+
This minor release introduces a new operator, `startWith`, which is meant to replace the `initialValue` operator.
4+
5+
## New features
6+
7+
### startWith operator
8+
9+
The new `startWith` operator replaces `initialValue` and behaves slightly differently: `startWith` returns a [memory stream](https://github.com/staltz/xstream#memorystream), 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 once, ever, and that the resulting stream is guaranteed to emit a value on subscription.
10+
11+
You can use startWith to turn 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.
12+
13+
<img src="assets/constraints.gif" />
14+
15+
```swift
16+
let axisCenterX = runtime.get(axisLine.layer).position.x()
17+
runtime.add(Draggable(), to: exampleView) { $0
18+
.startWith(exampleView.layer.position)
19+
.xLocked(to: axisCenterX)
20+
}
21+
runtime.add(Draggable(), to: axisLine) { $0.yLocked(to: axisLine.layer.position.y) }
22+
```
23+
24+
## New deprecations
25+
26+
- `initialValue(_:)` has been deprecated in favor of the new `startWith(_:)` operator.
27+
28+
## Source changes
29+
30+
* [Deprecate initialValue and provide startWith as a replacement.](https://github.com/material-motion/material-motion-swift/commit/2a5df59861c4ec0f737e2bc7e38d8bb0801e8e66) (Jeff Verkoeyen)
31+
* [Renamed normalized.swift to normalizedBy.swift.](https://github.com/material-motion/material-motion-swift/commit/8ff079b6ba1322f3fae47a6f2eb2d72bc2158203) (Jeff Verkoeyen)
32+
* [Rename unit test file rewriteTo.swift to rewriteToTests.swift.](https://github.com/material-motion/material-motion-swift/commit/0d81c70185865008282ee717e1bd7404227befe0) (Jeff Verkoeyen)
33+
34+
## API changes
35+
36+
Auto-generated by running:
37+
38+
apidiff origin/stable release-candidate swift MaterialMotion.xcworkspace MaterialMotion
39+
40+
## MotionObservableConvertible
41+
42+
*new* method: `startWith(_:)` in `MotionObservableConvertible`
43+
44+
*deprecated* method: `initialValue(_:)` in `MotionObservableConvertible`: Use `startWith(_:)` instead.
45+
46+
## Non-source changes
47+
48+
* [Fix README example.](https://github.com/material-motion/material-motion-swift/commit/21ab8263cc0f1bf0b0b7724954b55d9147c480d1) (Jeff Verkoeyen)
49+
* [Fix typo.](https://github.com/material-motion/material-motion-swift/commit/16fbf643a4873c4bc79da83119ed735168070b60) (Jeff Verkoeyen)
50+
151
# 1.1.0
252

353
This is our first minor release. It includes two new interactions and improvements to APIs for the common cases.

MaterialMotion.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22
s.name = "MaterialMotion"
33
s.summary = "Reactive motion driven by Core Animation."
4-
s.version = "1.1.0"
4+
s.version = "1.2.0"
55
s.authors = "The Material Motion Authors"
66
s.license = "Apache 2.0"
77
s.homepage = "https://github.com/material-motion/material-motion-swift"

Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ PODS:
33
- IndefiniteObservable (3.1.0):
44
- IndefiniteObservable/lib (= 3.1.0)
55
- IndefiniteObservable/lib (3.1.0)
6-
- MaterialMotion (1.1.0):
6+
- MaterialMotion (1.2.0):
77
- IndefiniteObservable (~> 3.0)
88

99
DEPENDENCIES:
@@ -17,7 +17,7 @@ EXTERNAL SOURCES:
1717
SPEC CHECKSUMS:
1818
CatalogByConvention: be55c2263132e4f9f59299ac8a528ee8715b3275
1919
IndefiniteObservable: 2789d61f487d8d37fa2b9c3153cc44d4447ff744
20-
MaterialMotion: 6ee4d44d39b074686d603c26c20a5816afdb50cd
20+
MaterialMotion: 4a4f155a35fce5e1dad7cc838719ef1c9c590dc6
2121

2222
PODFILE CHECKSUM: f503265a0d60526a0d28c96dd4bdcfb40fb562fc
2323

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ runtime.add(arcMove, to: <#view#>)</code></pre></td>
3333
<td align="center"><img src="assets/changedirection.gif" /></td>
3434
<td><pre><code class="language-swift">ChangeDirection</code></pre></td>
3535
<td><pre><code class="language-swift">runtime.add(ChangeDirection(withVelocityOf: gesture),
36-
to: <#view#>)</code></pre></td>
36+
to: <#direction#>)</code></pre></td>
3737
</tr>
3838
<tr>
3939
<td align="center"><img src="assets/directlymanipulable.gif" /></td>
@@ -181,7 +181,7 @@ Makes use of: `Transition` and `Tween`.
181181

182182
<img src="assets/materialexpansion.gif" />
183183

184-
A Material Design transition using assymetric transformations.
184+
A Material Design transition using asymetric transformations.
185185

186186
Makes use of: `Tween`.
187187

assets/constraints.gif

278 KB
Loading

examples/HowToUseReactiveConstraintsExample.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class HowToUseReactiveConstraintsExampleViewController: ExampleViewController {
3535

3636
let axisCenterX = runtime.get(axisLine.layer).position.x()
3737
runtime.add(Draggable(), to: exampleView) { $0
38-
.initialValue(exampleView.layer.position)
38+
.startWith(exampleView.layer.position)
3939
.xLocked(to: axisCenterX)
4040
}
4141

examples/apps/Catalog/MaterialMotionCatalog.xcodeproj/project.pbxproj

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
660DA3211E7A106D008F7401 /* TweenExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 660DA3201E7A106D008F7401 /* TweenExample.swift */; };
2121
6613A9DB1E832779004A3699 /* mergeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6613A9DA1E832779004A3699 /* mergeTests.swift */; };
2222
6613A9DD1E832913004A3699 /* rewriteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6613A9DC1E832913004A3699 /* rewriteTests.swift */; };
23-
6613A9DF1E8329DF004A3699 /* rewriteTo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6613A9DE1E8329DF004A3699 /* rewriteTo.swift */; };
23+
6613A9DF1E8329DF004A3699 /* rewriteToTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6613A9DE1E8329DF004A3699 /* rewriteToTests.swift */; };
2424
6613A9E11E832B18004A3699 /* rewriteRangeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6613A9E01E832B18004A3699 /* rewriteRangeTests.swift */; };
2525
6613A9E31E841461004A3699 /* anchorPointAdjustmentTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6613A9E21E841461004A3699 /* anchorPointAdjustmentTests.swift */; };
26-
6613A9E71E84170B004A3699 /* normalizeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6613A9E61E84170B004A3699 /* normalizeTests.swift */; };
26+
6613A9E71E84170B004A3699 /* normalizedByTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6613A9E61E84170B004A3699 /* normalizedByTests.swift */; };
2727
6613A9E91E841856004A3699 /* offsetByTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6613A9E81E841856004A3699 /* offsetByTests.swift */; };
2828
6613A9EB1E84188D004A3699 /* scaledByTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6613A9EA1E84188D004A3699 /* scaledByTests.swift */; };
2929
6613A9ED1E841C04004A3699 /* rubberBandedTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6613A9EC1E841C04004A3699 /* rubberBandedTests.swift */; };
@@ -63,7 +63,7 @@
6363
6695129B1E830AE500D8868D /* lowerBoundTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6695129A1E830AE500D8868D /* lowerBoundTests.swift */; };
6464
6695129D1E830B6E00D8868D /* upperBoundTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6695129C1E830B6E00D8868D /* upperBoundTests.swift */; };
6565
6695129F1E830C0800D8868D /* valveTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6695129E1E830C0800D8868D /* valveTests.swift */; };
66-
669512A11E830E1900D8868D /* initialValueTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 669512A01E830E1900D8868D /* initialValueTests.swift */; };
66+
669512A11E830E1900D8868D /* startWithTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 669512A01E830E1900D8868D /* startWithTests.swift */; };
6767
66BD3CCB1E8046AD00AA413C /* MaterialExpansionExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66BD3CCA1E8046AD00AA413C /* MaterialExpansionExample.swift */; };
6868
66DDFD0D1E71F0F100AA46B7 /* DraggableExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66DDFD0C1E71F0F100AA46B7 /* DraggableExample.swift */; };
6969
66DDFD121E71F39700AA46B7 /* ExampleViews.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66DDFD111E71F39700AA46B7 /* ExampleViews.swift */; };
@@ -102,10 +102,10 @@
102102
660DA3201E7A106D008F7401 /* TweenExample.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TweenExample.swift; path = ../../TweenExample.swift; sourceTree = "<group>"; };
103103
6613A9DA1E832779004A3699 /* mergeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = mergeTests.swift; sourceTree = "<group>"; };
104104
6613A9DC1E832913004A3699 /* rewriteTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = rewriteTests.swift; sourceTree = "<group>"; };
105-
6613A9DE1E8329DF004A3699 /* rewriteTo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = rewriteTo.swift; sourceTree = "<group>"; };
105+
6613A9DE1E8329DF004A3699 /* rewriteToTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = rewriteToTests.swift; sourceTree = "<group>"; };
106106
6613A9E01E832B18004A3699 /* rewriteRangeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = rewriteRangeTests.swift; sourceTree = "<group>"; };
107107
6613A9E21E841461004A3699 /* anchorPointAdjustmentTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = anchorPointAdjustmentTests.swift; sourceTree = "<group>"; };
108-
6613A9E61E84170B004A3699 /* normalizeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = normalizeTests.swift; sourceTree = "<group>"; };
108+
6613A9E61E84170B004A3699 /* normalizedByTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = normalizedByTests.swift; sourceTree = "<group>"; };
109109
6613A9E81E841856004A3699 /* offsetByTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = offsetByTests.swift; sourceTree = "<group>"; };
110110
6613A9EA1E84188D004A3699 /* scaledByTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = scaledByTests.swift; sourceTree = "<group>"; };
111111
6613A9EC1E841C04004A3699 /* rubberBandedTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = rubberBandedTests.swift; sourceTree = "<group>"; };
@@ -150,7 +150,7 @@
150150
6695129A1E830AE500D8868D /* lowerBoundTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = lowerBoundTests.swift; sourceTree = "<group>"; };
151151
6695129C1E830B6E00D8868D /* upperBoundTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = upperBoundTests.swift; sourceTree = "<group>"; };
152152
6695129E1E830C0800D8868D /* valveTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = valveTests.swift; sourceTree = "<group>"; };
153-
669512A01E830E1900D8868D /* initialValueTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = initialValueTests.swift; sourceTree = "<group>"; };
153+
669512A01E830E1900D8868D /* startWithTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = startWithTests.swift; sourceTree = "<group>"; };
154154
66BD3CCA1E8046AD00AA413C /* MaterialExpansionExample.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MaterialExpansionExample.swift; path = ../../MaterialExpansionExample.swift; sourceTree = "<group>"; };
155155
66DDFD0C1E71F0F100AA46B7 /* DraggableExample.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DraggableExample.swift; path = ../../DraggableExample.swift; sourceTree = "<group>"; };
156156
66DDFD111E71F39700AA46B7 /* ExampleViews.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExampleViews.swift; sourceTree = "<group>"; };
@@ -276,18 +276,18 @@
276276
669512921E8301D100D8868D /* dedupeTests.swift */,
277277
669512961E8305AC00D8868D /* delayTests.swift */,
278278
6605044D1E83146C009EDB8A /* distanceFromTests.swift */,
279-
669512A01E830E1900D8868D /* initialValueTests.swift */,
280279
66F2C3C81E83245800DD9728 /* invertedTests.swift */,
281280
6695129A1E830AE500D8868D /* lowerBoundTests.swift */,
282281
6613A9DA1E832779004A3699 /* mergeTests.swift */,
283-
6613A9E61E84170B004A3699 /* normalizeTests.swift */,
282+
6613A9E61E84170B004A3699 /* normalizedByTests.swift */,
284283
6613A9E81E841856004A3699 /* offsetByTests.swift */,
285284
6613A9DC1E832913004A3699 /* rewriteTests.swift */,
286285
6613A9E01E832B18004A3699 /* rewriteRangeTests.swift */,
287-
6613A9DE1E8329DF004A3699 /* rewriteTo.swift */,
286+
6613A9DE1E8329DF004A3699 /* rewriteToTests.swift */,
288287
6613A9EC1E841C04004A3699 /* rubberBandedTests.swift */,
289288
6613A9EA1E84188D004A3699 /* scaledByTests.swift */,
290289
6695128E1E82ED0900D8868D /* slopTests.swift */,
290+
669512A01E830E1900D8868D /* startWithTests.swift */,
291291
6613A9EE1E8420CE004A3699 /* thresholdTests.swift */,
292292
6613A9F01E84214F004A3699 /* thresholdRangeTests.swift */,
293293
6695129C1E830B6E00D8868D /* upperBoundTests.swift */,
@@ -656,7 +656,7 @@
656656
6613A9F51E842FF5004A3699 /* yLockedToTests.swift in Sources */,
657657
669512891E82E8CB00D8868D /* _rememberTests.swift in Sources */,
658658
669512741E82E68900D8868D /* SubtractableTests.swift in Sources */,
659-
6613A9DF1E8329DF004A3699 /* rewriteTo.swift in Sources */,
659+
6613A9DF1E8329DF004A3699 /* rewriteToTests.swift in Sources */,
660660
6613A9DD1E832913004A3699 /* rewriteTests.swift in Sources */,
661661
6613A9DB1E832779004A3699 /* mergeTests.swift in Sources */,
662662
6695129B1E830AE500D8868D /* lowerBoundTests.swift in Sources */,
@@ -666,9 +666,9 @@
666666
6686F01C1E77293100F97CC4 /* MotionRuntimeTests.swift in Sources */,
667667
669512931E8301D100D8868D /* dedupeTests.swift in Sources */,
668668
6613A9F31E842F8B004A3699 /* xLockedToTests.swift in Sources */,
669-
6613A9E71E84170B004A3699 /* normalizeTests.swift in Sources */,
669+
6613A9E71E84170B004A3699 /* normalizedByTests.swift in Sources */,
670670
6613A9EB1E84188D004A3699 /* scaledByTests.swift in Sources */,
671-
669512A11E830E1900D8868D /* initialValueTests.swift in Sources */,
671+
669512A11E830E1900D8868D /* startWithTests.swift in Sources */,
672672
669512871E82E8CB00D8868D /* _mapTests.swift in Sources */,
673673
6613A9EF1E8420CE004A3699 /* thresholdTests.swift in Sources */,
674674
6695128B1E82E8CB00D8868D /* yTests.swift in Sources */,
File renamed without changes.

src/operators/initialValue.swift renamed to src/operators/startWith.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,19 @@ import Foundation
1919
extension MotionObservableConvertible {
2020

2121
/**
22-
Emits the provided value and then subscribes upstream and emits all subsequent values with no
23-
modification.
22+
Emits the provided value and then emits the values emitted by the upstream.
2423

25-
Helpful for priming a stream with an initial value.
24+
The returned stream will cache the last value received and immediately emit it on subscription.
25+
The returned stream is therefor guaranteed to always immediately emit a value upon subscription.
2626
*/
27+
public func startWith(_ value: T) -> MotionObservable<T> {
28+
return MotionObservable(self.metadata.createChild(Metadata(#function, type: .constraint, args: [value]))) { observer in
29+
observer.next(value)
30+
return self.asStream().subscribeAndForward(to: observer).unsubscribe
31+
}._remember()
32+
}
33+
34+
@available(*, deprecated, message: "Use startWith() instead.")
2735
public func initialValue(_ value: T) -> MotionObservable<T> {
2836
return MotionObservable(self.metadata.createChild(Metadata(#function, type: .constraint, args: [value]))) { observer in
2937
observer.next(value)

0 commit comments

Comments
 (0)