File tree 3 files changed +64
-1
lines changed
3 files changed +64
-1
lines changed Original file line number Diff line number Diff line change 922
922
isa = XCBuildConfiguration;
923
923
buildSettings = {
924
924
BUNDLE_LOADER = "$(TEST_HOST)";
925
+ INFOPLIST_FILE = "";
925
926
LD_RUNPATH_SEARCH_PATHS = (
926
927
"$(inherited)",
927
928
"@executable_path/Frameworks",
1078
1079
buildSettings = {
1079
1080
BUNDLE_LOADER = "$(TEST_HOST)";
1080
1081
ENABLE_BITCODE = YES;
1082
+ INFOPLIST_FILE = "$(SRCROOT)/Sources/Info.plist";
1081
1083
LD_RUNPATH_SEARCH_PATHS = (
1082
1084
"$(inherited)",
1083
1085
"@executable_path/Frameworks",
1212
1214
isa = XCBuildConfiguration;
1213
1215
buildSettings = {
1214
1216
BUNDLE_LOADER = "$(TEST_HOST)";
1217
+ INFOPLIST_FILE = "";
1215
1218
LD_RUNPATH_SEARCH_PATHS = (
1216
1219
"$(inherited)",
1217
1220
"@executable_path/Frameworks",
1288
1291
buildSettings = {
1289
1292
BUNDLE_LOADER = "$(TEST_HOST)";
1290
1293
ENABLE_BITCODE = YES;
1294
+ INFOPLIST_FILE = "$(SRCROOT)/Sources/Info.plist";
1291
1295
LD_RUNPATH_SEARCH_PATHS = (
1292
1296
"$(inherited)",
1293
1297
"@executable_path/Frameworks",
Original file line number Diff line number Diff line change @@ -71,9 +71,11 @@ public class Output<Value>: Unbindable {
71
71
/**
72
72
`initial` allows the caller to specify an initial value to be populated into the Output through another mechanism
73
73
other than the initialiser. If a value is already populated, this function just returns the receiver without doing
74
- anything
74
+ anything.
75
75
- Parameter value: The initial value
76
76
- Returns: The same Output but with the initial value populated
77
+ - Note: This is useful when needing to setup a functional chain with an initial value that does not
78
+ trigger the chain to occur, e.g. setting the initial value at the end.
77
79
*/
78
80
public func initial( _ value: Value ) -> Output < Value > {
79
81
if self . value == nil {
@@ -241,3 +243,27 @@ public extension Output {
241
243
return output
242
244
}
243
245
}
246
+
247
+ public extension Output where Value: Equatable {
248
+
249
+ /**
250
+ Returns a new output that filters out any contiguous repeating `Value`.
251
+ - Returns: A new `Output` which only emits a new value, when the new value is not equal to the previous value
252
+ */
253
+ func ignoringDuplicates( ) -> Output < Value > {
254
+ let output = Output < Value > ( )
255
+
256
+ var initial = self . value
257
+
258
+ let filtered = filter { value in
259
+ value != initial
260
+ }
261
+
262
+ filtered. bind { new in
263
+ initial = self . value
264
+ output. update ( withValue: new)
265
+ }
266
+
267
+ return filtered
268
+ }
269
+ }
Original file line number Diff line number Diff line change @@ -333,6 +333,39 @@ final class OutputTests: XCTestCase {
333
333
XCTAssertEqual ( combined. latest, 10 )
334
334
}
335
335
336
+ func testIgnoringDuplicates( ) {
337
+ let output = Output < Bool > ( )
338
+
339
+ var callCounter = 0
340
+ var lastValue : Bool ?
341
+
342
+ output
343
+ . ignoringDuplicates ( )
344
+ . bind { value in
345
+ XCTAssertNotEqual ( lastValue, value)
346
+ lastValue = value
347
+ callCounter += 1
348
+ }
349
+
350
+ output. update ( withValue: true )
351
+ output. update ( withValue: true )
352
+ output. update ( withValue: true )
353
+ XCTAssertEqual ( callCounter, 1 )
354
+
355
+ output. update ( withValue: false )
356
+ XCTAssertEqual ( callCounter, 2 )
357
+
358
+ output. update ( withValue: true )
359
+ output. update ( withValue: true )
360
+ output. update ( withValue: true )
361
+ XCTAssertEqual ( callCounter, 3 )
362
+
363
+ output. update ( withValue: false )
364
+ output. update ( withValue: false )
365
+ output. update ( withValue: false )
366
+ XCTAssertEqual ( callCounter, 4 )
367
+ }
368
+
336
369
func testDebug( ) {
337
370
let printer = PrinterMock ( )
338
371
let output1 = Output < Bool > ( printer: printer)
You can’t perform that action at this time.
0 commit comments