From ec6d4b1410ee46ce0a46854fb14bfb9ddc0074fa Mon Sep 17 00:00:00 2001 From: Jeff Verkoeyen Date: Mon, 5 Dec 2016 16:23:57 -0800 Subject: [PATCH] Set next in the ValueObserver wrather than wrap it. Reviewers: O4 Material Motion Apple platform reviewers, O2 Material Motion, markwei Reviewed By: O4 Material Motion Apple platform reviewers, O2 Material Motion, markwei Tags: #material_motion Differential Revision: http://codereview.cc/D2121 --- src/IndefiniteObservable.swift | 10 +++------- tests/unit/ObservableTests.swift | 4 ++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/IndefiniteObservable.swift b/src/IndefiniteObservable.swift index 27eb831..0ae94bc 100644 --- a/src/IndefiniteObservable.swift +++ b/src/IndefiniteObservable.swift @@ -107,15 +107,11 @@ public let noopUnsubscription: (() -> Void)? = nil public final class ValueObserver { public typealias Value = T - init(_ next: @escaping (Value) -> Void) { - _next = next + public init(_ next: @escaping (T) -> Void) { + self.next = next } - public func next(_ value: Value) { - _next(value) - } - - private let _next: (Value) -> Void + public let next: (T) -> Void } // MARK: Private diff --git a/tests/unit/ObservableTests.swift b/tests/unit/ObservableTests.swift index c5e3578..a880f78 100644 --- a/tests/unit/ObservableTests.swift +++ b/tests/unit/ObservableTests.swift @@ -128,8 +128,8 @@ class ObservableTests: XCTestCase { func testFilteringValues() { let value = CGPoint(x: 0, y: 10) let observable = IndefiniteObservable<(Bool, CGPoint)> { observer in - observer.next((false, value)) - observer.next((true, value)) + observer.next(false, value) + observer.next(true, value) return noopUnsubscription }