From 29a4eb13b59ab47bdd01663e388f2896af99b3f1 Mon Sep 17 00:00:00 2001 From: Christopher Liscio Date: Fri, 25 Sep 2015 09:39:54 -0400 Subject: [PATCH 1/9] Port to use the swift2 branch from ReactiveCocoa --- Cartfile | 2 +- Cartfile.private | 4 +- Cartfile.resolved | 9 +-- Carthage/Checkouts/Box | 2 +- Carthage/Checkouts/Nimble | 1 - Carthage/Checkouts/Quick | 1 - Carthage/Checkouts/ReactiveCocoa | 2 +- Carthage/Checkouts/Result | 2 +- EditableProperty.xcodeproj/project.pbxproj | 32 +++++++- .../EditableProperty.xcscmblueprint | 30 ++++++++ .../xcschemes/EditableProperty-Mac.xcscheme | 13 ++-- .../xcschemes/EditableProperty-iOS.xcscheme | 13 ++-- EditableProperty/Committed.swift | 15 ++-- EditableProperty/EditableProperty.swift | 75 ++++++++++--------- EditableProperty/Info.plist | 2 +- .../EditablePropertySpec.swift | 1 - EditablePropertyTests/Info.plist | 2 +- 17 files changed, 131 insertions(+), 75 deletions(-) delete mode 160000 Carthage/Checkouts/Nimble delete mode 160000 Carthage/Checkouts/Quick create mode 100644 EditableProperty.xcodeproj/project.xcworkspace/xcshareddata/EditableProperty.xcscmblueprint diff --git a/Cartfile b/Cartfile index 02a6698..0a6c99d 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "ReactiveCocoa/ReactiveCocoa" "v3.0-beta.8" +github "ReactiveCocoa/ReactiveCocoa" "swift2" diff --git a/Cartfile.private b/Cartfile.private index af8de78..f19b4f4 100644 --- a/Cartfile.private +++ b/Cartfile.private @@ -1,3 +1,3 @@ -github "Quick/Quick" ~> 0.3 -github "Quick/Nimble" ~> 0.4 +github "Quick/Quick" "v0.6.0" +github "Quick/Nimble" "v2.0.0-rc.3" github "jspahrsummers/xcconfigs" ~> 0.8 diff --git a/Cartfile.resolved b/Cartfile.resolved index a6ef940..28231fe 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,6 +1,5 @@ -github "robrix/Box" "1.2.2" -github "Quick/Nimble" "v0.4.2" -github "Quick/Quick" "v0.3.1" +github "Quick/Nimble" "v2.0.0-rc.3" +github "Quick/Quick" "v0.6.0" +github "antitypical/Result" "0.6.0-beta.3" github "jspahrsummers/xcconfigs" "0.8.1" -github "antitypical/Result" "0.4.4" -github "ReactiveCocoa/ReactiveCocoa" "b89e1b73f2d1c6a99e0916f699ab6dcda71c74b5" +github "ReactiveCocoa/ReactiveCocoa" "5b18ece9a34597c3dec6ad88d1038d936f7881ba" diff --git a/Carthage/Checkouts/Box b/Carthage/Checkouts/Box index bbe4e61..8f53d61 160000 --- a/Carthage/Checkouts/Box +++ b/Carthage/Checkouts/Box @@ -1 +1 @@ -Subproject commit bbe4e612a03ffe0bbb0e2e476c2be4534b6777a5 +Subproject commit 8f53d619da3600ff6e236f4d2f557ec133c7d243 diff --git a/Carthage/Checkouts/Nimble b/Carthage/Checkouts/Nimble deleted file mode 160000 index 8927113..0000000 --- a/Carthage/Checkouts/Nimble +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8927113f877f32c8a01b41b746c4ac261b42c48e diff --git a/Carthage/Checkouts/Quick b/Carthage/Checkouts/Quick deleted file mode 160000 index 8bf96f7..0000000 --- a/Carthage/Checkouts/Quick +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8bf96f708924d728dab5f0cf7543b6f1b896a209 diff --git a/Carthage/Checkouts/ReactiveCocoa b/Carthage/Checkouts/ReactiveCocoa index b89e1b7..5b18ece 160000 --- a/Carthage/Checkouts/ReactiveCocoa +++ b/Carthage/Checkouts/ReactiveCocoa @@ -1 +1 @@ -Subproject commit b89e1b73f2d1c6a99e0916f699ab6dcda71c74b5 +Subproject commit 5b18ece9a34597c3dec6ad88d1038d936f7881ba diff --git a/Carthage/Checkouts/Result b/Carthage/Checkouts/Result index 81b1896..918d63b 160000 --- a/Carthage/Checkouts/Result +++ b/Carthage/Checkouts/Result @@ -1 +1 @@ -Subproject commit 81b189645babd30c6f70ed3f82a83988a467fb02 +Subproject commit 918d63b99b76d424c299c8b5efea7dc3e8d286fc diff --git a/EditableProperty.xcodeproj/project.pbxproj b/EditableProperty.xcodeproj/project.pbxproj index 2ba1572..baf8ccb 100644 --- a/EditableProperty.xcodeproj/project.pbxproj +++ b/EditableProperty.xcodeproj/project.pbxproj @@ -135,7 +135,7 @@ D8D608971B2FC9D00068D35B /* Result.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Result.framework; path = Carthage/Build/Mac/Result.framework; sourceTree = SOURCE_ROOT; }; D8D6089A1B2FCA060068D35B /* ReactiveCocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ReactiveCocoa.framework; path = Carthage/Build/Mac/ReactiveCocoa.framework; sourceTree = SOURCE_ROOT; }; D8D608A41B2FCB7E0068D35B /* EditableProperty.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = EditableProperty.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - D8D608AE1B2FCB7F0068D35B /* EditablePropertyTest-iOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "EditablePropertyTest-iOS.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; + D8D608AE1B2FCB7F0068D35B /* EditablePropertyTests-iOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "EditablePropertyTests-iOS.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; D8D608C11B2FCC510068D35B /* Box.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Box.framework; path = Carthage/Build/iOS/Box.framework; sourceTree = SOURCE_ROOT; }; D8D608C21B2FCC510068D35B /* ReactiveCocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ReactiveCocoa.framework; path = Carthage/Build/iOS/ReactiveCocoa.framework; sourceTree = SOURCE_ROOT; }; D8D608C31B2FCC510068D35B /* Result.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Result.framework; path = Carthage/Build/iOS/Result.framework; sourceTree = SOURCE_ROOT; }; @@ -224,7 +224,7 @@ D03A80A51AF36BD70047F5AE /* EditableProperty.framework */, D03A80B01AF36BD70047F5AE /* EditablePropertyTests-Mac.xctest */, D8D608A41B2FCB7E0068D35B /* EditableProperty.framework */, - D8D608AE1B2FCB7F0068D35B /* EditablePropertyTest-iOS.xctest */, + D8D608AE1B2FCB7F0068D35B /* EditablePropertyTests-iOS.xctest */, ); name = Products; sourceTree = ""; @@ -505,7 +505,7 @@ ); name = "EditablePropertyTests-iOS"; productName = "EditableProperty-iOSTests"; - productReference = D8D608AE1B2FCB7F0068D35B /* EditablePropertyTest-iOS.xctest */; + productReference = D8D608AE1B2FCB7F0068D35B /* EditablePropertyTests-iOS.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; /* End PBXNativeTarget section */ @@ -514,7 +514,9 @@ D03A809C1AF36BD70047F5AE /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0630; + LastSwiftMigration = 0700; + LastSwiftUpdateCheck = 0700; + LastUpgradeCheck = 0700; ORGANIZATIONNAME = ReactiveCocoa; TargetAttributes = { D03A80A41AF36BD70047F5AE = { @@ -640,8 +642,11 @@ baseConfigurationReference = D03A80C71AF36BFC0047F5AE /* Debug.xcconfig */; buildSettings = { CURRENT_PROJECT_VERSION = 1; + ENABLE_TESTABILITY = YES; + GCC_NO_COMMON_BLOCKS = YES; IPHONEOS_DEPLOYMENT_TARGET = 8.0; MACOSX_DEPLOYMENT_TARGET = 10.9; + ONLY_ACTIVE_ARCH = YES; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -652,6 +657,7 @@ baseConfigurationReference = D03A80C91AF36BFC0047F5AE /* Release.xcconfig */; buildSettings = { CURRENT_PROJECT_VERSION = 1; + GCC_NO_COMMON_BLOCKS = YES; IPHONEOS_DEPLOYMENT_TARGET = 8.0; MACOSX_DEPLOYMENT_TARGET = 10.9; VERSIONING_SYSTEM = "apple-generic"; @@ -672,6 +678,7 @@ ); FRAMEWORK_VERSION = A; INFOPLIST_FILE = EditableProperty/Info.plist; + PRODUCT_BUNDLE_IDENTIFIER = "org.ReactiveCocoa.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(PROJECT_NAME)"; }; name = Debug; @@ -689,6 +696,7 @@ ); FRAMEWORK_VERSION = A; INFOPLIST_FILE = EditableProperty/Info.plist; + PRODUCT_BUNDLE_IDENTIFIER = "org.ReactiveCocoa.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(PROJECT_NAME)"; }; name = Release; @@ -705,6 +713,7 @@ ); INFOPLIST_FILE = EditablePropertyTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "org.ReactiveCocoa.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; }; @@ -722,6 +731,7 @@ ); INFOPLIST_FILE = EditablePropertyTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "org.ReactiveCocoa.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; @@ -731,6 +741,7 @@ baseConfigurationReference = D03A80C81AF36BFC0047F5AE /* Profile.xcconfig */; buildSettings = { CURRENT_PROJECT_VERSION = 1; + GCC_NO_COMMON_BLOCKS = YES; IPHONEOS_DEPLOYMENT_TARGET = 8.0; MACOSX_DEPLOYMENT_TARGET = 10.9; VERSIONING_SYSTEM = "apple-generic"; @@ -751,6 +762,7 @@ ); FRAMEWORK_VERSION = A; INFOPLIST_FILE = EditableProperty/Info.plist; + PRODUCT_BUNDLE_IDENTIFIER = "org.ReactiveCocoa.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(PROJECT_NAME)"; }; name = Profile; @@ -767,6 +779,7 @@ ); INFOPLIST_FILE = EditablePropertyTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "org.ReactiveCocoa.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Profile; @@ -776,6 +789,7 @@ baseConfigurationReference = D03A80CA1AF36BFC0047F5AE /* Test.xcconfig */; buildSettings = { CURRENT_PROJECT_VERSION = 1; + GCC_NO_COMMON_BLOCKS = YES; IPHONEOS_DEPLOYMENT_TARGET = 8.0; MACOSX_DEPLOYMENT_TARGET = 10.9; VERSIONING_SYSTEM = "apple-generic"; @@ -796,6 +810,7 @@ ); FRAMEWORK_VERSION = A; INFOPLIST_FILE = EditableProperty/Info.plist; + PRODUCT_BUNDLE_IDENTIFIER = "org.ReactiveCocoa.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(PROJECT_NAME)"; }; name = Test; @@ -812,6 +827,7 @@ ); INFOPLIST_FILE = EditablePropertyTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "org.ReactiveCocoa.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; }; @@ -830,6 +846,7 @@ ); INFOPLIST_FILE = "$(SRCROOT)/EditableProperty/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "org.ReactiveCocoa.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(PROJECT_NAME)"; }; name = Debug; @@ -847,6 +864,7 @@ ); INFOPLIST_FILE = "$(SRCROOT)/EditableProperty/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "org.ReactiveCocoa.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(PROJECT_NAME)"; }; name = Test; @@ -864,6 +882,7 @@ ); INFOPLIST_FILE = "$(SRCROOT)/EditableProperty/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "org.ReactiveCocoa.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(PROJECT_NAME)"; }; name = Release; @@ -881,6 +900,7 @@ ); INFOPLIST_FILE = "$(SRCROOT)/EditableProperty/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "org.ReactiveCocoa.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(PROJECT_NAME)"; }; name = Profile; @@ -896,6 +916,7 @@ ); INFOPLIST_FILE = EditablePropertyTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "org.ReactiveCocoa.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -911,6 +932,7 @@ ); INFOPLIST_FILE = EditablePropertyTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "org.ReactiveCocoa.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Test; @@ -926,6 +948,7 @@ ); INFOPLIST_FILE = EditablePropertyTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "org.ReactiveCocoa.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; @@ -941,6 +964,7 @@ ); INFOPLIST_FILE = EditablePropertyTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "org.ReactiveCocoa.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Profile; diff --git a/EditableProperty.xcodeproj/project.xcworkspace/xcshareddata/EditableProperty.xcscmblueprint b/EditableProperty.xcodeproj/project.xcworkspace/xcshareddata/EditableProperty.xcscmblueprint new file mode 100644 index 0000000..cdec954 --- /dev/null +++ b/EditableProperty.xcodeproj/project.xcworkspace/xcshareddata/EditableProperty.xcscmblueprint @@ -0,0 +1,30 @@ +{ + "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "1D7898204F0A200CCD7DCD44C6DD7CFCE6DBAD95", + "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : { + + }, + "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { + "1D7898204F0A200CCD7DCD44C6DD7CFCE6DBAD95" : 0, + "E084C86B03F81D63323C9E7510697EA528A758C7" : 0 + }, + "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "6EEAD2AA-65C6-4EBD-8E24-B8512896CFE5", + "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { + "1D7898204F0A200CCD7DCD44C6DD7CFCE6DBAD95" : "EditableProperty\/", + "E084C86B03F81D63323C9E7510697EA528A758C7" : "EditableProperty\/Carthage\/Checkouts\/xcconfigs\/" + }, + "DVTSourceControlWorkspaceBlueprintNameKey" : "EditableProperty", + "DVTSourceControlWorkspaceBlueprintVersion" : 204, + "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "EditableProperty.xcodeproj", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [ + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "github.com:liscio\/EditableProperty.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "1D7898204F0A200CCD7DCD44C6DD7CFCE6DBAD95" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/jspahrsummers\/xcconfigs.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "E084C86B03F81D63323C9E7510697EA528A758C7" + } + ] +} \ No newline at end of file diff --git a/EditableProperty.xcodeproj/xcshareddata/xcschemes/EditableProperty-Mac.xcscheme b/EditableProperty.xcodeproj/xcshareddata/xcschemes/EditableProperty-Mac.xcscheme index d31e1f2..054edbc 100644 --- a/EditableProperty.xcodeproj/xcshareddata/xcschemes/EditableProperty-Mac.xcscheme +++ b/EditableProperty.xcodeproj/xcshareddata/xcschemes/EditableProperty-Mac.xcscheme @@ -1,6 +1,6 @@ + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -62,15 +62,18 @@ ReferencedContainer = "container:EditableProperty.xcodeproj"> + + + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -62,15 +62,18 @@ ReferencedContainer = "container:EditableProperty.xcodeproj"> + + { /// The change is an automatic update to a new default value. - case DefaultValue(Box) + case DefaultValue(Value) /// The change is a new value that has been explicitly set _without_ an /// editor. /// /// This might occur from setting `value` directly, or by explicitly binding /// signals, producers, or other properties to the EditableProperty. - case ExplicitUpdate(Box) + case ExplicitUpdate(Value) /// The value was validated and committed by the given editor. - case ValidatedEdit(Box, Editor) + case ValidatedEdit(Value, Editor) /// The value that was committed. public var value: Value { switch self { case let .DefaultValue(value): - return value.value + return value case let .ExplicitUpdate(value): - return value.value + return value case let .ValidatedEdit(value, _): - return value.value + return value } } @@ -55,7 +54,7 @@ public func == (lhs: Committed { public init(defaultValue: P, editsTakePriority: Bool) { (validationErrors, validationErrorsSink) = Signal.pipe() - _committedValue = MutableProperty(.DefaultValue(Box(defaultValue.value))) + _committedValue = MutableProperty(.DefaultValue(defaultValue.value)) var defaults = defaultValue.producer - |> map { Committed.DefaultValue(Box($0)) } + .map { Committed.DefaultValue($0) } if editsTakePriority { let hasBeenEdited = _committedValue.producer - |> filter { $0.isEdit } - |> map { _ in () } + .filter { $0.isEdit } + .map { _ in () } defaults = defaults - |> takeUntil(hasBeenEdited) + .takeUntil(hasBeenEdited) } _committedValue <~ defaults @@ -61,19 +60,13 @@ extension EditableProperty: MutablePropertyType { } set(value) { - _committedValue.value = .ExplicitUpdate(Box(value)) + _committedValue.value = .ExplicitUpdate(value) } } public var producer: SignalProducer { return _committedValue.producer - |> map { $0.value } - } -} - -extension EditableProperty: SinkType { - public func put(value: Value) { - self.value = value + .map { $0.value } } } @@ -90,29 +83,29 @@ extension EditableProperty: SinkType { /// property. public func <~ (property: EditableProperty, editor: Editor) -> Disposable { let validatedEdits = editor.edits - |> map(liftSignal) + .map(liftSignal) // We only care about the latest edit. - |> flatMap(FlattenStrategy.Latest) { [weak property] editSession -> SignalProducer in + .flatMap(FlattenStrategy.Latest) { [weak property] editSession -> SignalProducer in let sessionCompleted: SignalProducer<(), NoError> = editSession - |> then(.empty) - |> catch { _ in .empty } + .then(.empty) + .flatMapError { _ in .empty } let committedValues = (property?._committedValue.producer ?? .empty) - |> promoteErrors(ValidationError.self) - |> takeUntil(sessionCompleted) + .promoteErrors(ValidationError.self) + .takeUntil(sessionCompleted) return combineLatest(committedValues, editSession) // We only care about the result of merging the latest values. - |> flatMap(.Latest) { committed, proposed in + .flatMap(FlattenStrategy.Latest) { committed, proposed in return editor.mergeCommittedValue(committed, intoProposedValue: proposed) } // Wait until validation completes, then use the final value for // the property's value. If the signal never sends anything, // don't update the property. - |> takeLast(1) + .takeLast(1) // If interrupted or errored, just complete (to cancel the edit). - |> ignoreInterruption - |> catch { error in + .ignoreInterruption() + .flatMapError { error in if let property = property { sendNext(property.validationErrorsSink, error) } @@ -120,7 +113,7 @@ public func <~ (property: EditableProperty map { Committed.ValidatedEdit(Box($0), editor) } + .map { Committed.ValidatedEdit($0, editor) } return property._committedValue <~ validatedEdits } @@ -136,18 +129,26 @@ private func liftSignal(signal: Signal) -> SignalProducer(signal: Signal) -> Signal { - return Signal { observer in - return signal.observe(Signal.Observer { event in - switch event { - case .Interrupted: - sendCompleted(observer) - - default: - observer.put(event) +private extension Signal { + /// Ignores any Interrupted event on the input signal, translating it to + /// Completed instead. + func ignoreInterruption() -> Signal { + return Signal { observer in + return self.observe { event in + switch event { + case .Interrupted: + sendCompleted(observer) + + default: + observer(event) + } } - }) + } } } + +private extension SignalProducer { + func ignoreInterruption() -> SignalProducer { + return lift { $0.ignoreInterruption() } + } +} \ No newline at end of file diff --git a/EditableProperty/Info.plist b/EditableProperty/Info.plist index 1a67194..4b3a120 100644 --- a/EditableProperty/Info.plist +++ b/EditableProperty/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - org.ReactiveCocoa.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/EditablePropertyTests/EditablePropertySpec.swift b/EditablePropertyTests/EditablePropertySpec.swift index 08a6375..8e88968 100644 --- a/EditablePropertyTests/EditablePropertySpec.swift +++ b/EditablePropertyTests/EditablePropertySpec.swift @@ -8,7 +8,6 @@ import Nimble import Quick - import EditableProperty import ReactiveCocoa diff --git a/EditablePropertyTests/Info.plist b/EditablePropertyTests/Info.plist index eeeaa04..ba72822 100644 --- a/EditablePropertyTests/Info.plist +++ b/EditablePropertyTests/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - org.ReactiveCocoa.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName From ae65c3fd28175abe5e412bf8dd7a02e0b089ff00 Mon Sep 17 00:00:00 2001 From: Christopher Liscio Date: Fri, 25 Sep 2015 10:51:51 -0400 Subject: [PATCH 2/9] Remove unneeded reference to Box.framework --- EditableProperty.xcodeproj/project.pbxproj | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/EditableProperty.xcodeproj/project.pbxproj b/EditableProperty.xcodeproj/project.pbxproj index baf8ccb..6b4be80 100644 --- a/EditableProperty.xcodeproj/project.pbxproj +++ b/EditableProperty.xcodeproj/project.pbxproj @@ -17,27 +17,22 @@ D03A80C21AF36BF10047F5AE /* EditableProperty.swift in Sources */ = {isa = PBXBuildFile; fileRef = D03A80C11AF36BF10047F5AE /* EditableProperty.swift */; }; D03A80ED1AF36C140047F5AE /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D03A80EB1AF36C140047F5AE /* Nimble.framework */; }; D03A80EE1AF36C140047F5AE /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D03A80EC1AF36C140047F5AE /* Quick.framework */; }; - D8D608981B2FC9D00068D35B /* Box.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8D608961B2FC9D00068D35B /* Box.framework */; }; D8D608991B2FC9D00068D35B /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8D608971B2FC9D00068D35B /* Result.framework */; }; D8D6089B1B2FCA060068D35B /* ReactiveCocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8D6089A1B2FCA060068D35B /* ReactiveCocoa.framework */; }; - D8D6089C1B2FCA710068D35B /* Box.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = D8D608961B2FC9D00068D35B /* Box.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; D8D6089D1B2FCA710068D35B /* ReactiveCocoa.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = D8D6089A1B2FCA060068D35B /* ReactiveCocoa.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; D8D6089E1B2FCA710068D35B /* Result.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = D8D608971B2FC9D00068D35B /* Result.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; D8D608AF1B2FCB7F0068D35B /* EditableProperty.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8D608A41B2FCB7E0068D35B /* EditableProperty.framework */; }; - D8D608C41B2FCC510068D35B /* Box.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8D608C11B2FCC510068D35B /* Box.framework */; }; D8D608C51B2FCC510068D35B /* ReactiveCocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8D608C21B2FCC510068D35B /* ReactiveCocoa.framework */; }; D8D608C61B2FCC510068D35B /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8D608C31B2FCC510068D35B /* Result.framework */; }; D8D608C91B2FCCDF0068D35B /* EditableProperty.h in Headers */ = {isa = PBXBuildFile; fileRef = D03A80AA1AF36BD70047F5AE /* EditableProperty.h */; settings = {ATTRIBUTES = (Public, ); }; }; D8D608CA1B2FCCE50068D35B /* Committed.swift in Sources */ = {isa = PBXBuildFile; fileRef = D00E59891AF3FFA3000DAF8A /* Committed.swift */; }; D8D608CB1B2FCCE50068D35B /* Editor.swift in Sources */ = {isa = PBXBuildFile; fileRef = D00E598A1AF3FFA3000DAF8A /* Editor.swift */; }; D8D608CC1B2FCCE50068D35B /* EditableProperty.swift in Sources */ = {isa = PBXBuildFile; fileRef = D03A80C11AF36BF10047F5AE /* EditableProperty.swift */; }; - D8D608CD1B2FCCF80068D35B /* Box.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8D608C11B2FCC510068D35B /* Box.framework */; }; D8D608CE1B2FCCF80068D35B /* ReactiveCocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8D608C21B2FCC510068D35B /* ReactiveCocoa.framework */; }; D8D608CF1B2FCCF80068D35B /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8D608C31B2FCC510068D35B /* Result.framework */; }; D8D608D01B2FCD020068D35B /* EditablePropertySpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = D00E598F1AF404E5000DAF8A /* EditablePropertySpec.swift */; }; D8D608D41B2FCD3B0068D35B /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8D608D21B2FCD3B0068D35B /* Nimble.framework */; }; D8D608D51B2FCD3B0068D35B /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8D608D31B2FCD3B0068D35B /* Quick.framework */; }; - D8D608D81B2FCDA90068D35B /* Box.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = D8D608C11B2FCC510068D35B /* Box.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; D8D608D91B2FCDA90068D35B /* ReactiveCocoa.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = D8D608C21B2FCC510068D35B /* ReactiveCocoa.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; D8D608DA1B2FCDA90068D35B /* Result.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = D8D608C31B2FCC510068D35B /* Result.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; D8D608DB1B2FCDA90068D35B /* Nimble.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = D8D608D21B2FCD3B0068D35B /* Nimble.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; @@ -68,7 +63,6 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - D8D6089C1B2FCA710068D35B /* Box.framework in Copy Frameworks */, D8D6089D1B2FCA710068D35B /* ReactiveCocoa.framework in Copy Frameworks */, D8D6089E1B2FCA710068D35B /* Result.framework in Copy Frameworks */, D00E59921AF406E3000DAF8A /* Quick.framework in Copy Frameworks */, @@ -83,7 +77,6 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - D8D608D81B2FCDA90068D35B /* Box.framework in CopyFiles */, D8D608D91B2FCDA90068D35B /* ReactiveCocoa.framework in CopyFiles */, D8D608DA1B2FCDA90068D35B /* Result.framework in CopyFiles */, D8D608DB1B2FCDA90068D35B /* Nimble.framework in CopyFiles */, @@ -131,12 +124,10 @@ D03A80E61AF36BFC0047F5AE /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; D03A80EB1AF36C140047F5AE /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nimble.framework; path = Carthage/Build/Mac/Nimble.framework; sourceTree = SOURCE_ROOT; }; D03A80EC1AF36C140047F5AE /* Quick.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quick.framework; path = Carthage/Build/Mac/Quick.framework; sourceTree = SOURCE_ROOT; }; - D8D608961B2FC9D00068D35B /* Box.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Box.framework; path = Carthage/Build/Mac/Box.framework; sourceTree = SOURCE_ROOT; }; D8D608971B2FC9D00068D35B /* Result.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Result.framework; path = Carthage/Build/Mac/Result.framework; sourceTree = SOURCE_ROOT; }; D8D6089A1B2FCA060068D35B /* ReactiveCocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ReactiveCocoa.framework; path = Carthage/Build/Mac/ReactiveCocoa.framework; sourceTree = SOURCE_ROOT; }; D8D608A41B2FCB7E0068D35B /* EditableProperty.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = EditableProperty.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D8D608AE1B2FCB7F0068D35B /* EditablePropertyTests-iOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "EditablePropertyTests-iOS.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; - D8D608C11B2FCC510068D35B /* Box.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Box.framework; path = Carthage/Build/iOS/Box.framework; sourceTree = SOURCE_ROOT; }; D8D608C21B2FCC510068D35B /* ReactiveCocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ReactiveCocoa.framework; path = Carthage/Build/iOS/ReactiveCocoa.framework; sourceTree = SOURCE_ROOT; }; D8D608C31B2FCC510068D35B /* Result.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Result.framework; path = Carthage/Build/iOS/Result.framework; sourceTree = SOURCE_ROOT; }; D8D608D21B2FCD3B0068D35B /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nimble.framework; path = Carthage/Build/iOS/Nimble.framework; sourceTree = SOURCE_ROOT; }; @@ -148,7 +139,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - D8D608981B2FC9D00068D35B /* Box.framework in Frameworks */, D8D6089B1B2FCA060068D35B /* ReactiveCocoa.framework in Frameworks */, D8D608991B2FC9D00068D35B /* Result.framework in Frameworks */, ); @@ -168,7 +158,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - D8D608C41B2FCC510068D35B /* Box.framework in Frameworks */, D8D608C51B2FCC510068D35B /* ReactiveCocoa.framework in Frameworks */, D8D608C61B2FCC510068D35B /* Result.framework in Frameworks */, ); @@ -179,7 +168,6 @@ buildActionMask = 2147483647; files = ( D8D608D41B2FCD3B0068D35B /* Nimble.framework in Frameworks */, - D8D608CD1B2FCCF80068D35B /* Box.framework in Frameworks */, D8D608D51B2FCD3B0068D35B /* Quick.framework in Frameworks */, D8D608CE1B2FCCF80068D35B /* ReactiveCocoa.framework in Frameworks */, D8D608AF1B2FCB7F0068D35B /* EditableProperty.framework in Frameworks */, @@ -377,7 +365,6 @@ D8D608C71B2FCC5A0068D35B /* Mac */ = { isa = PBXGroup; children = ( - D8D608961B2FC9D00068D35B /* Box.framework */, D8D6089A1B2FCA060068D35B /* ReactiveCocoa.framework */, D8D608971B2FC9D00068D35B /* Result.framework */, ); @@ -387,7 +374,6 @@ D8D608C81B2FCC740068D35B /* iOS */ = { isa = PBXGroup; children = ( - D8D608C11B2FCC510068D35B /* Box.framework */, D8D608C21B2FCC510068D35B /* ReactiveCocoa.framework */, D8D608C31B2FCC510068D35B /* Result.framework */, ); From 40c5a5c1a1c42495bbc272f4dfe418a2e8ffd9c6 Mon Sep 17 00:00:00 2001 From: Christopher Liscio Date: Fri, 25 Sep 2015 12:38:58 -0400 Subject: [PATCH 3/9] Make the framework extension-safe --- EditableProperty.xcodeproj/project.pbxproj | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/EditableProperty.xcodeproj/project.pbxproj b/EditableProperty.xcodeproj/project.pbxproj index 6b4be80..86b35df 100644 --- a/EditableProperty.xcodeproj/project.pbxproj +++ b/EditableProperty.xcodeproj/project.pbxproj @@ -655,6 +655,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = D03A80E41AF36BFC0047F5AE /* Mac-Framework.xcconfig */; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; FRAMEWORK_SEARCH_PATHS = ( @@ -673,6 +674,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = D03A80E41AF36BFC0047F5AE /* Mac-Framework.xcconfig */; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; FRAMEWORK_SEARCH_PATHS = ( @@ -739,6 +741,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = D03A80E41AF36BFC0047F5AE /* Mac-Framework.xcconfig */; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; FRAMEWORK_SEARCH_PATHS = ( @@ -787,6 +790,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = D03A80E41AF36BFC0047F5AE /* Mac-Framework.xcconfig */; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; FRAMEWORK_SEARCH_PATHS = ( @@ -823,6 +827,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = D03A80DE1AF36BFC0047F5AE /* iOS-Framework.xcconfig */; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -841,6 +846,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = D03A80DE1AF36BFC0047F5AE /* iOS-Framework.xcconfig */; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -859,6 +865,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = D03A80DE1AF36BFC0047F5AE /* iOS-Framework.xcconfig */; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -877,6 +884,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = D03A80DE1AF36BFC0047F5AE /* iOS-Framework.xcconfig */; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; From 91cb412b23a7bb5d4a74384c33a3b16051394cc5 Mon Sep 17 00:00:00 2001 From: Christopher Liscio Date: Thu, 15 Oct 2015 17:28:30 -0400 Subject: [PATCH 4/9] Fixing to point at the latest release --- .gitmodules | 15 ++++++--------- Cartfile | 2 +- Cartfile.resolved | 4 ++-- Carthage/Checkouts/Box | 1 - Carthage/Checkouts/Nimble | 1 + Carthage/Checkouts/Quick | 1 + Carthage/Checkouts/ReactiveCocoa | 2 +- Carthage/Checkouts/Result | 2 +- 8 files changed, 13 insertions(+), 15 deletions(-) delete mode 160000 Carthage/Checkouts/Box create mode 160000 Carthage/Checkouts/Nimble create mode 160000 Carthage/Checkouts/Quick diff --git a/.gitmodules b/.gitmodules index 60079d8..c3994c5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,18 +1,15 @@ -[submodule "Carthage/Checkouts/Box"] - path = Carthage/Checkouts/Box - url = https://github.com/robrix/Box.git +[submodule "Carthage/Checkouts/Result"] + path = Carthage/Checkouts/Result + url = https://github.com/antitypical/Result.git +[submodule "Carthage/Checkouts/xcconfigs"] + path = Carthage/Checkouts/xcconfigs + url = https://github.com/jspahrsummers/xcconfigs.git [submodule "Carthage/Checkouts/Nimble"] path = Carthage/Checkouts/Nimble url = https://github.com/Quick/Nimble.git [submodule "Carthage/Checkouts/Quick"] path = Carthage/Checkouts/Quick url = https://github.com/Quick/Quick.git -[submodule "Carthage/Checkouts/xcconfigs"] - path = Carthage/Checkouts/xcconfigs - url = https://github.com/jspahrsummers/xcconfigs.git -[submodule "Carthage/Checkouts/Result"] - path = Carthage/Checkouts/Result - url = https://github.com/antitypical/Result.git [submodule "Carthage/Checkouts/ReactiveCocoa"] path = Carthage/Checkouts/ReactiveCocoa url = https://github.com/ReactiveCocoa/ReactiveCocoa.git diff --git a/Cartfile b/Cartfile index 0a6c99d..de7d65c 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "ReactiveCocoa/ReactiveCocoa" "swift2" +github "ReactiveCocoa/ReactiveCocoa" "v4.0-alpha.1" diff --git a/Cartfile.resolved b/Cartfile.resolved index 28231fe..4f4c460 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,5 +1,5 @@ github "Quick/Nimble" "v2.0.0-rc.3" github "Quick/Quick" "v0.6.0" -github "antitypical/Result" "0.6.0-beta.3" +github "antitypical/Result" "76f9a972ed61ff872b731460bc610c8acbfae58c" github "jspahrsummers/xcconfigs" "0.8.1" -github "ReactiveCocoa/ReactiveCocoa" "5b18ece9a34597c3dec6ad88d1038d936f7881ba" +github "ReactiveCocoa/ReactiveCocoa" "v4.0-alpha.1" diff --git a/Carthage/Checkouts/Box b/Carthage/Checkouts/Box deleted file mode 160000 index 8f53d61..0000000 --- a/Carthage/Checkouts/Box +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8f53d619da3600ff6e236f4d2f557ec133c7d243 diff --git a/Carthage/Checkouts/Nimble b/Carthage/Checkouts/Nimble new file mode 160000 index 0000000..e239824 --- /dev/null +++ b/Carthage/Checkouts/Nimble @@ -0,0 +1 @@ +Subproject commit e239824d84105de9e13b815006bc36e938cdd030 diff --git a/Carthage/Checkouts/Quick b/Carthage/Checkouts/Quick new file mode 160000 index 0000000..b47b9eb --- /dev/null +++ b/Carthage/Checkouts/Quick @@ -0,0 +1 @@ +Subproject commit b47b9ebf97bc8e377070bd1e868c9f89b870c4fc diff --git a/Carthage/Checkouts/ReactiveCocoa b/Carthage/Checkouts/ReactiveCocoa index 5b18ece..8ebff4f 160000 --- a/Carthage/Checkouts/ReactiveCocoa +++ b/Carthage/Checkouts/ReactiveCocoa @@ -1 +1 @@ -Subproject commit 5b18ece9a34597c3dec6ad88d1038d936f7881ba +Subproject commit 8ebff4f192ad11dfc62c55e8151c235d005f390b diff --git a/Carthage/Checkouts/Result b/Carthage/Checkouts/Result index 918d63b..76f9a97 160000 --- a/Carthage/Checkouts/Result +++ b/Carthage/Checkouts/Result @@ -1 +1 @@ -Subproject commit 918d63b99b76d424c299c8b5efea7dc3e8d286fc +Subproject commit 76f9a972ed61ff872b731460bc610c8acbfae58c From 3b003d7f1ec18ad87fe0ddaf03a1a089077ac8f2 Mon Sep 17 00:00:00 2001 From: Christopher Liscio Date: Wed, 6 Jan 2016 12:48:35 -0500 Subject: [PATCH 5/9] Porting to RAC 4.0.0-RC.1 --- Cartfile | 2 +- Cartfile.resolved | 4 ++-- Carthage/Checkouts/ReactiveCocoa | 2 +- Carthage/Checkouts/Result | 2 +- EditableProperty.xcodeproj/project.pbxproj | 4 ++-- EditableProperty/EditableProperty.swift | 12 ++++++------ 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cartfile b/Cartfile index de7d65c..ce85889 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "ReactiveCocoa/ReactiveCocoa" "v4.0-alpha.1" +github "ReactiveCocoa/ReactiveCocoa" "v4.0.0-RC.1" diff --git a/Cartfile.resolved b/Cartfile.resolved index 4f4c460..5f9dede 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,5 +1,5 @@ github "Quick/Nimble" "v2.0.0-rc.3" github "Quick/Quick" "v0.6.0" -github "antitypical/Result" "76f9a972ed61ff872b731460bc610c8acbfae58c" +github "antitypical/Result" "1.0.1" github "jspahrsummers/xcconfigs" "0.8.1" -github "ReactiveCocoa/ReactiveCocoa" "v4.0-alpha.1" +github "ReactiveCocoa/ReactiveCocoa" "v4.0.0-RC.1" diff --git a/Carthage/Checkouts/ReactiveCocoa b/Carthage/Checkouts/ReactiveCocoa index 8ebff4f..4490dad 160000 --- a/Carthage/Checkouts/ReactiveCocoa +++ b/Carthage/Checkouts/ReactiveCocoa @@ -1 +1 @@ -Subproject commit 8ebff4f192ad11dfc62c55e8151c235d005f390b +Subproject commit 4490dadeaaf0399d61ad575726f7dd1b0088a93e diff --git a/Carthage/Checkouts/Result b/Carthage/Checkouts/Result index 76f9a97..9f2c108 160000 --- a/Carthage/Checkouts/Result +++ b/Carthage/Checkouts/Result @@ -1 +1 @@ -Subproject commit 76f9a972ed61ff872b731460bc610c8acbfae58c +Subproject commit 9f2c108adeb7427782d69381e2414f7175b373cc diff --git a/EditableProperty.xcodeproj/project.pbxproj b/EditableProperty.xcodeproj/project.pbxproj index 86b35df..dacf384 100644 --- a/EditableProperty.xcodeproj/project.pbxproj +++ b/EditableProperty.xcodeproj/project.pbxproj @@ -87,7 +87,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - D00E59891AF3FFA3000DAF8A /* Committed.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Committed.swift; sourceTree = ""; }; + D00E59891AF3FFA3000DAF8A /* Committed.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Committed.swift; sourceTree = ""; usesTabs = 1; }; D00E598A1AF3FFA3000DAF8A /* Editor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Editor.swift; sourceTree = ""; }; D00E598F1AF404E5000DAF8A /* EditablePropertySpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EditablePropertySpec.swift; sourceTree = ""; }; D03A80A51AF36BD70047F5AE /* EditableProperty.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = EditableProperty.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -95,7 +95,7 @@ D03A80AA1AF36BD70047F5AE /* EditableProperty.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EditableProperty.h; sourceTree = ""; }; D03A80B01AF36BD70047F5AE /* EditablePropertyTests-Mac.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "EditablePropertyTests-Mac.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; D03A80B61AF36BD70047F5AE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - D03A80C11AF36BF10047F5AE /* EditableProperty.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EditableProperty.swift; sourceTree = ""; }; + D03A80C11AF36BF10047F5AE /* EditableProperty.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EditableProperty.swift; sourceTree = ""; usesTabs = 1; }; D03A80C51AF36BFC0047F5AE /* Common.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Common.xcconfig; sourceTree = ""; }; D03A80C71AF36BFC0047F5AE /* Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; D03A80C81AF36BFC0047F5AE /* Profile.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Profile.xcconfig; sourceTree = ""; }; diff --git a/EditableProperty/EditableProperty.swift b/EditableProperty/EditableProperty.swift index 04654be..3106d16 100644 --- a/EditableProperty/EditableProperty.swift +++ b/EditableProperty/EditableProperty.swift @@ -7,8 +7,8 @@ import ReactiveCocoa public final class EditableProperty { /// The current value of the property, along with information about how that /// value was obtained. - public var committedValue: PropertyOf> { - return PropertyOf(_committedValue) + public var committedValue: AnyProperty> { + return AnyProperty(_committedValue) } private let _committedValue: MutableProperty> @@ -49,7 +49,7 @@ public final class EditableProperty { } deinit { - sendCompleted(validationErrorsSink) + validationErrorsSink.sendCompleted() } } @@ -107,7 +107,7 @@ public func <~ (property: EditableProperty Date: Wed, 6 Jan 2016 12:52:16 -0500 Subject: [PATCH 6/9] Fix the test spec as well --- EditablePropertyTests/EditablePropertySpec.swift | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/EditablePropertyTests/EditablePropertySpec.swift b/EditablePropertyTests/EditablePropertySpec.swift index 8e88968..5b25fc1 100644 --- a/EditablePropertyTests/EditablePropertySpec.swift +++ b/EditablePropertyTests/EditablePropertySpec.swift @@ -16,7 +16,8 @@ typealias TestEditor = Editor class EditablePropertySpec: QuickSpec { override func spec() { it("should do some binding magic") { - let defaultValue = MutableProperty(0) + let defaultValue + = MutableProperty(0) let property = EditableProperty(defaultValue: defaultValue, editsTakePriority: false) expect(property.value).to(equal(defaultValue.value)) @@ -33,13 +34,13 @@ class EditablePropertySpec: QuickSpec { let tryEdit: Int -> () = { proposed in let (editSignal, editSink) = TestEditor.EditSession.pipe() - sendNext(editsSink, editSignal) + editsSink.sendNext(editSignal) expect(property.value).to(equal(defaultValue.value)) - sendNext(editSink, proposed) + editSink.sendNext(proposed) expect(property.value).to(equal(defaultValue.value)) - sendCompleted(editSink) + editSink.sendCompleted() } tryEdit(2) From 3da114ae8e07a243cbcefab0aa12852693b7eca8 Mon Sep 17 00:00:00 2001 From: Christopher Liscio Date: Thu, 7 Jan 2016 10:49:38 -0500 Subject: [PATCH 7/9] Add a few helpful operators In practice, there aren't many reasons to send more than a single value across each "edit session", and using a MutableProperty is less awkward than a signal/observer pair. This changeset introduces a pair of operators that allow a Signal{,Producer} to be directed into a MutableProperty that holds the current EditSession for an Editor. --- EditableProperty.xcodeproj/project.pbxproj | 8 ++- EditableProperty/Operators.swift | 38 ++++++++++++ .../EditablePropertySpec.swift | 59 ++++++++++++++++++- 3 files changed, 102 insertions(+), 3 deletions(-) create mode 100644 EditableProperty/Operators.swift diff --git a/EditableProperty.xcodeproj/project.pbxproj b/EditableProperty.xcodeproj/project.pbxproj index dacf384..bc72356 100644 --- a/EditableProperty.xcodeproj/project.pbxproj +++ b/EditableProperty.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 833859A11C3EBBD500EE372F /* Operators.swift in Sources */ = {isa = PBXBuildFile; fileRef = 833859A01C3EBBD500EE372F /* Operators.swift */; }; + 833859A21C3EBBD500EE372F /* Operators.swift in Sources */ = {isa = PBXBuildFile; fileRef = 833859A01C3EBBD500EE372F /* Operators.swift */; }; D00E598B1AF3FFA3000DAF8A /* Committed.swift in Sources */ = {isa = PBXBuildFile; fileRef = D00E59891AF3FFA3000DAF8A /* Committed.swift */; }; D00E598C1AF3FFA3000DAF8A /* Editor.swift in Sources */ = {isa = PBXBuildFile; fileRef = D00E598A1AF3FFA3000DAF8A /* Editor.swift */; }; D00E59901AF404E5000DAF8A /* EditablePropertySpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = D00E598F1AF404E5000DAF8A /* EditablePropertySpec.swift */; }; @@ -87,9 +89,10 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 833859A01C3EBBD500EE372F /* Operators.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Operators.swift; sourceTree = ""; }; D00E59891AF3FFA3000DAF8A /* Committed.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Committed.swift; sourceTree = ""; usesTabs = 1; }; D00E598A1AF3FFA3000DAF8A /* Editor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Editor.swift; sourceTree = ""; }; - D00E598F1AF404E5000DAF8A /* EditablePropertySpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EditablePropertySpec.swift; sourceTree = ""; }; + D00E598F1AF404E5000DAF8A /* EditablePropertySpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EditablePropertySpec.swift; sourceTree = ""; usesTabs = 1; }; D03A80A51AF36BD70047F5AE /* EditableProperty.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = EditableProperty.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D03A80A91AF36BD70047F5AE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; D03A80AA1AF36BD70047F5AE /* EditableProperty.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EditableProperty.h; sourceTree = ""; }; @@ -184,6 +187,7 @@ D00E59891AF3FFA3000DAF8A /* Committed.swift */, D00E598A1AF3FFA3000DAF8A /* Editor.swift */, D03A80C11AF36BF10047F5AE /* EditableProperty.swift */, + 833859A01C3EBBD500EE372F /* Operators.swift */, ); name = API; sourceTree = ""; @@ -576,6 +580,7 @@ buildActionMask = 2147483647; files = ( D00E598B1AF3FFA3000DAF8A /* Committed.swift in Sources */, + 833859A11C3EBBD500EE372F /* Operators.swift in Sources */, D00E598C1AF3FFA3000DAF8A /* Editor.swift in Sources */, D03A80C21AF36BF10047F5AE /* EditableProperty.swift in Sources */, ); @@ -594,6 +599,7 @@ buildActionMask = 2147483647; files = ( D8D608CB1B2FCCE50068D35B /* Editor.swift in Sources */, + 833859A21C3EBBD500EE372F /* Operators.swift in Sources */, D8D608CA1B2FCCE50068D35B /* Committed.swift in Sources */, D8D608CC1B2FCCE50068D35B /* EditableProperty.swift in Sources */, ); diff --git a/EditableProperty/Operators.swift b/EditableProperty/Operators.swift new file mode 100644 index 0000000..95b2873 --- /dev/null +++ b/EditableProperty/Operators.swift @@ -0,0 +1,38 @@ +// +// Operators.swift +// EditableProperty +// +// Created by Christopher Liscio on 1/7/16. +// Copyright © 2016 ReactiveCocoa. All rights reserved. +// + +import Foundation +import ReactiveCocoa + +/// Attaches a SignalProducer to a MutableProperty of edit sessions (as defined +/// by Editor.EditSession). This allows for far simpler "sessions" that crop up +/// in practice when binding changes from UI elements that require validation from +/// an associated editor. +public func <~(session: MutableProperty>, producer: Producer) { + producer.startWithNext { value in + let (editSignal, editSink) = Signal.pipe() + session.value = editSignal + + editSink.sendNext(value) + editSink.sendCompleted() + } +} + +/// Attaches a Signal to a MutableProperty of edit sessions (as defined +/// by Editor.EditSession). This allows for far simpler "sessions" that crop up +/// in practice when binding changes from UI elements that require validation from +/// an associated editor. +public func <~(session: MutableProperty>, producer: Producer) { + producer.observeNext { value in + let (editSignal, editSink) = Signal.pipe() + session.value = editSignal + + editSink.sendNext(value) + editSink.sendCompleted() + } +} diff --git a/EditablePropertyTests/EditablePropertySpec.swift b/EditablePropertyTests/EditablePropertySpec.swift index 5b25fc1..9323f7d 100644 --- a/EditablePropertyTests/EditablePropertySpec.swift +++ b/EditablePropertyTests/EditablePropertySpec.swift @@ -16,8 +16,7 @@ typealias TestEditor = Editor class EditablePropertySpec: QuickSpec { override func spec() { it("should do some binding magic") { - let defaultValue - = MutableProperty(0) + let defaultValue = MutableProperty(0) let property = EditableProperty(defaultValue: defaultValue, editsTakePriority: false) expect(property.value).to(equal(defaultValue.value)) @@ -55,5 +54,61 @@ class EditablePropertySpec: QuickSpec { tryEdit(4) expect(property.value).to(equal(4)) } + + context("when working with a property holding edit sessions") { + let defaultValue = MutableProperty(0) + + let property = EditableProperty(defaultValue: defaultValue, editsTakePriority: false) + expect(property.value).to(equal(defaultValue.value)) + + let editsProperty = MutableProperty(.never) + let editor = Editor(edits: editsProperty.producer) { committed, proposed in + return SignalProducer(value: max(committed.value, proposed)) + } + + property <~ editor + + beforeEach { + defaultValue.value = 1 + expect(property.value).to(equal(defaultValue.value)) + } + + it("should take values coming across a signal") { + let (valueSignal, valueSink) = Signal.pipe() + + editsProperty <~ valueSignal + + valueSink.sendNext(2) + expect(property.value).to(equal(2)) + + defaultValue.value = 3 + expect(property.value).to(equal(defaultValue.value)) + + valueSink.sendNext(2) + expect(property.value).to(equal(defaultValue.value)) + + valueSink.sendNext(4) + expect(property.value).to(equal(4)) + } + + it("should take values coming across a signalProducer") { + let (valueProducer, valueSink) = SignalProducer.buffer(0) + + editsProperty <~ valueProducer + + valueSink.sendNext(2) + expect(property.value).to(equal(2)) + + defaultValue.value = 3 + expect(property.value).to(equal(defaultValue.value)) + + valueSink.sendNext(2) + expect(property.value).to(equal(defaultValue.value)) + + valueSink.sendNext(4) + expect(property.value).to(equal(4)) + } + } + } } From 0c650020593790e6d145924b69813119ebde9e27 Mon Sep 17 00:00:00 2001 From: Christopher Liscio Date: Sat, 9 Jan 2016 16:18:49 -0500 Subject: [PATCH 8/9] Revert "Add a few helpful operators" This reverts commit 3da114ae8e07a243cbcefab0aa12852693b7eca8. --- EditableProperty.xcodeproj/project.pbxproj | 8 +-- EditableProperty/Operators.swift | 38 ------------ .../EditablePropertySpec.swift | 59 +------------------ 3 files changed, 3 insertions(+), 102 deletions(-) delete mode 100644 EditableProperty/Operators.swift diff --git a/EditableProperty.xcodeproj/project.pbxproj b/EditableProperty.xcodeproj/project.pbxproj index bc72356..dacf384 100644 --- a/EditableProperty.xcodeproj/project.pbxproj +++ b/EditableProperty.xcodeproj/project.pbxproj @@ -7,8 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 833859A11C3EBBD500EE372F /* Operators.swift in Sources */ = {isa = PBXBuildFile; fileRef = 833859A01C3EBBD500EE372F /* Operators.swift */; }; - 833859A21C3EBBD500EE372F /* Operators.swift in Sources */ = {isa = PBXBuildFile; fileRef = 833859A01C3EBBD500EE372F /* Operators.swift */; }; D00E598B1AF3FFA3000DAF8A /* Committed.swift in Sources */ = {isa = PBXBuildFile; fileRef = D00E59891AF3FFA3000DAF8A /* Committed.swift */; }; D00E598C1AF3FFA3000DAF8A /* Editor.swift in Sources */ = {isa = PBXBuildFile; fileRef = D00E598A1AF3FFA3000DAF8A /* Editor.swift */; }; D00E59901AF404E5000DAF8A /* EditablePropertySpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = D00E598F1AF404E5000DAF8A /* EditablePropertySpec.swift */; }; @@ -89,10 +87,9 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 833859A01C3EBBD500EE372F /* Operators.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Operators.swift; sourceTree = ""; }; D00E59891AF3FFA3000DAF8A /* Committed.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Committed.swift; sourceTree = ""; usesTabs = 1; }; D00E598A1AF3FFA3000DAF8A /* Editor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Editor.swift; sourceTree = ""; }; - D00E598F1AF404E5000DAF8A /* EditablePropertySpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EditablePropertySpec.swift; sourceTree = ""; usesTabs = 1; }; + D00E598F1AF404E5000DAF8A /* EditablePropertySpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EditablePropertySpec.swift; sourceTree = ""; }; D03A80A51AF36BD70047F5AE /* EditableProperty.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = EditableProperty.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D03A80A91AF36BD70047F5AE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; D03A80AA1AF36BD70047F5AE /* EditableProperty.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EditableProperty.h; sourceTree = ""; }; @@ -187,7 +184,6 @@ D00E59891AF3FFA3000DAF8A /* Committed.swift */, D00E598A1AF3FFA3000DAF8A /* Editor.swift */, D03A80C11AF36BF10047F5AE /* EditableProperty.swift */, - 833859A01C3EBBD500EE372F /* Operators.swift */, ); name = API; sourceTree = ""; @@ -580,7 +576,6 @@ buildActionMask = 2147483647; files = ( D00E598B1AF3FFA3000DAF8A /* Committed.swift in Sources */, - 833859A11C3EBBD500EE372F /* Operators.swift in Sources */, D00E598C1AF3FFA3000DAF8A /* Editor.swift in Sources */, D03A80C21AF36BF10047F5AE /* EditableProperty.swift in Sources */, ); @@ -599,7 +594,6 @@ buildActionMask = 2147483647; files = ( D8D608CB1B2FCCE50068D35B /* Editor.swift in Sources */, - 833859A21C3EBBD500EE372F /* Operators.swift in Sources */, D8D608CA1B2FCCE50068D35B /* Committed.swift in Sources */, D8D608CC1B2FCCE50068D35B /* EditableProperty.swift in Sources */, ); diff --git a/EditableProperty/Operators.swift b/EditableProperty/Operators.swift deleted file mode 100644 index 95b2873..0000000 --- a/EditableProperty/Operators.swift +++ /dev/null @@ -1,38 +0,0 @@ -// -// Operators.swift -// EditableProperty -// -// Created by Christopher Liscio on 1/7/16. -// Copyright © 2016 ReactiveCocoa. All rights reserved. -// - -import Foundation -import ReactiveCocoa - -/// Attaches a SignalProducer to a MutableProperty of edit sessions (as defined -/// by Editor.EditSession). This allows for far simpler "sessions" that crop up -/// in practice when binding changes from UI elements that require validation from -/// an associated editor. -public func <~(session: MutableProperty>, producer: Producer) { - producer.startWithNext { value in - let (editSignal, editSink) = Signal.pipe() - session.value = editSignal - - editSink.sendNext(value) - editSink.sendCompleted() - } -} - -/// Attaches a Signal to a MutableProperty of edit sessions (as defined -/// by Editor.EditSession). This allows for far simpler "sessions" that crop up -/// in practice when binding changes from UI elements that require validation from -/// an associated editor. -public func <~(session: MutableProperty>, producer: Producer) { - producer.observeNext { value in - let (editSignal, editSink) = Signal.pipe() - session.value = editSignal - - editSink.sendNext(value) - editSink.sendCompleted() - } -} diff --git a/EditablePropertyTests/EditablePropertySpec.swift b/EditablePropertyTests/EditablePropertySpec.swift index 9323f7d..5b25fc1 100644 --- a/EditablePropertyTests/EditablePropertySpec.swift +++ b/EditablePropertyTests/EditablePropertySpec.swift @@ -16,7 +16,8 @@ typealias TestEditor = Editor class EditablePropertySpec: QuickSpec { override func spec() { it("should do some binding magic") { - let defaultValue = MutableProperty(0) + let defaultValue + = MutableProperty(0) let property = EditableProperty(defaultValue: defaultValue, editsTakePriority: false) expect(property.value).to(equal(defaultValue.value)) @@ -54,61 +55,5 @@ class EditablePropertySpec: QuickSpec { tryEdit(4) expect(property.value).to(equal(4)) } - - context("when working with a property holding edit sessions") { - let defaultValue = MutableProperty(0) - - let property = EditableProperty(defaultValue: defaultValue, editsTakePriority: false) - expect(property.value).to(equal(defaultValue.value)) - - let editsProperty = MutableProperty(.never) - let editor = Editor(edits: editsProperty.producer) { committed, proposed in - return SignalProducer(value: max(committed.value, proposed)) - } - - property <~ editor - - beforeEach { - defaultValue.value = 1 - expect(property.value).to(equal(defaultValue.value)) - } - - it("should take values coming across a signal") { - let (valueSignal, valueSink) = Signal.pipe() - - editsProperty <~ valueSignal - - valueSink.sendNext(2) - expect(property.value).to(equal(2)) - - defaultValue.value = 3 - expect(property.value).to(equal(defaultValue.value)) - - valueSink.sendNext(2) - expect(property.value).to(equal(defaultValue.value)) - - valueSink.sendNext(4) - expect(property.value).to(equal(4)) - } - - it("should take values coming across a signalProducer") { - let (valueProducer, valueSink) = SignalProducer.buffer(0) - - editsProperty <~ valueProducer - - valueSink.sendNext(2) - expect(property.value).to(equal(2)) - - defaultValue.value = 3 - expect(property.value).to(equal(defaultValue.value)) - - valueSink.sendNext(2) - expect(property.value).to(equal(defaultValue.value)) - - valueSink.sendNext(4) - expect(property.value).to(equal(4)) - } - } - } } From 7ca8359309e500a842ef8237b0ab798c2745f5e6 Mon Sep 17 00:00:00 2001 From: Christopher Liscio Date: Mon, 15 Feb 2016 13:57:04 -0500 Subject: [PATCH 9/9] Pick up the latest ReactiveCocoa, Quick, Nimble Had to make a few modifications here & there to make it work. --- Cartfile | 2 +- Cartfile.private | 4 ++-- Cartfile.resolved | 8 +++---- Carthage/Checkouts/Nimble | 2 +- Carthage/Checkouts/Quick | 2 +- Carthage/Checkouts/ReactiveCocoa | 2 +- Carthage/Checkouts/Result | 2 +- EditableProperty/EditableProperty.swift | 23 +++++++++++++------ EditableProperty/Editor.swift | 1 + .../EditablePropertySpec.swift | 1 + 10 files changed, 29 insertions(+), 18 deletions(-) diff --git a/Cartfile b/Cartfile index ce85889..313e02e 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "ReactiveCocoa/ReactiveCocoa" "v4.0.0-RC.1" +github "ReactiveCocoa/ReactiveCocoa" ~> 4.0.0 diff --git a/Cartfile.private b/Cartfile.private index f19b4f4..26a4387 100644 --- a/Cartfile.private +++ b/Cartfile.private @@ -1,3 +1,3 @@ -github "Quick/Quick" "v0.6.0" -github "Quick/Nimble" "v2.0.0-rc.3" +github "Quick/Quick" ~> 0.8.0 +github "Quick/Nimble" ~> 3.0.0 github "jspahrsummers/xcconfigs" ~> 0.8 diff --git a/Cartfile.resolved b/Cartfile.resolved index 5f9dede..7fc0c82 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,5 +1,5 @@ -github "Quick/Nimble" "v2.0.0-rc.3" -github "Quick/Quick" "v0.6.0" -github "antitypical/Result" "1.0.1" +github "Quick/Nimble" "v3.1.0" +github "Quick/Quick" "v0.8.0" +github "antitypical/Result" "1.0.2" github "jspahrsummers/xcconfigs" "0.8.1" -github "ReactiveCocoa/ReactiveCocoa" "v4.0.0-RC.1" +github "ReactiveCocoa/ReactiveCocoa" "v4.0.1" diff --git a/Carthage/Checkouts/Nimble b/Carthage/Checkouts/Nimble index e239824..72878d6 160000 --- a/Carthage/Checkouts/Nimble +++ b/Carthage/Checkouts/Nimble @@ -1 +1 @@ -Subproject commit e239824d84105de9e13b815006bc36e938cdd030 +Subproject commit 72878d6622cf8362d3507cd2e3d341b06580f451 diff --git a/Carthage/Checkouts/Quick b/Carthage/Checkouts/Quick index b47b9eb..e0ce8a8 160000 --- a/Carthage/Checkouts/Quick +++ b/Carthage/Checkouts/Quick @@ -1 +1 @@ -Subproject commit b47b9ebf97bc8e377070bd1e868c9f89b870c4fc +Subproject commit e0ce8a820ff0acf8b7fedcab27186736b51412b8 diff --git a/Carthage/Checkouts/ReactiveCocoa b/Carthage/Checkouts/ReactiveCocoa index 4490dad..def976d 160000 --- a/Carthage/Checkouts/ReactiveCocoa +++ b/Carthage/Checkouts/ReactiveCocoa @@ -1 +1 @@ -Subproject commit 4490dadeaaf0399d61ad575726f7dd1b0088a93e +Subproject commit def976d4ef5f3e38786a478a673db7c3f9a1d719 diff --git a/Carthage/Checkouts/Result b/Carthage/Checkouts/Result index 9f2c108..382f933 160000 --- a/Carthage/Checkouts/Result +++ b/Carthage/Checkouts/Result @@ -1 +1 @@ -Subproject commit 9f2c108adeb7427782d69381e2414f7175b373cc +Subproject commit 382f9339404d24f632a5f98453c1e08a5ea55904 diff --git a/EditableProperty/EditableProperty.swift b/EditableProperty/EditableProperty.swift index 3106d16..31ecdc6 100644 --- a/EditableProperty/EditableProperty.swift +++ b/EditableProperty/EditableProperty.swift @@ -1,10 +1,11 @@ import ReactiveCocoa +import Result /// A property of type `Value` that Editors can propose and commit changes to. /// /// This can be used to implement multi-way bindings, where each "side" of the /// binding is a separate editor that ignores changes made by itself. -public final class EditableProperty { +public final class EditableProperty: MutablePropertyType { /// The current value of the property, along with information about how that /// value was obtained. public var committedValue: AnyProperty> { @@ -48,12 +49,6 @@ public final class EditableProperty { self.init(defaultValue: ConstantProperty(defaultValue), editsTakePriority: true) } - deinit { - validationErrorsSink.sendCompleted() - } -} - -extension EditableProperty: MutablePropertyType { public var value: Value { get { return _committedValue.value.value @@ -68,6 +63,20 @@ extension EditableProperty: MutablePropertyType { return _committedValue.producer .map { $0.value } } + + /// A signal that will send the property's changes over time, + /// then complete when the property has deinitialized. + public lazy var signal: Signal = { [unowned self] in + var extractedSignal: Signal! + self.producer.startWithSignal { signal, _ in + extractedSignal = signal + } + return extractedSignal + }() + + deinit { + validationErrorsSink.sendCompleted() + } } /// Attaches an Editor to an EditableProperty, so that any edits will be diff --git a/EditableProperty/Editor.swift b/EditableProperty/Editor.swift index e481e01..19f27e4 100644 --- a/EditableProperty/Editor.swift +++ b/EditableProperty/Editor.swift @@ -1,4 +1,5 @@ import ReactiveCocoa +import Result /// Represents an editor that can propose changes to properties, and then commit /// those changes when editing has completed. diff --git a/EditablePropertyTests/EditablePropertySpec.swift b/EditablePropertyTests/EditablePropertySpec.swift index 5b25fc1..b95777f 100644 --- a/EditablePropertyTests/EditablePropertySpec.swift +++ b/EditablePropertyTests/EditablePropertySpec.swift @@ -9,6 +9,7 @@ import Nimble import Quick import EditableProperty +import Result import ReactiveCocoa typealias TestEditor = Editor