{"action":"created","comment":{"url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/pulls/comments/64136430","id":64136430,"diff_hunk":"@@ -5,69 +5,182 @@ import enum Result.NoError\n public protocol PropertyType {\n \tassociatedtype Value\n \n-\t/// The current value of the property.\n-\tvar value: Value { get }\n-\n \t/// A producer for Signals that will send the property's current value,\n-\t/// followed by all changes over time.\n+\t/// followed by all changes over time, then complete when the property has\n+\t/// deinitialized.\n \tvar producer: SignalProducer<Value, NoError> { get }\n \n \t/// A signal that will send the property's changes over time.\n \tvar signal: Signal<Value, NoError> { get }\n+\n+\t/// Performs an arbitrary action using the current value of the\n+\t/// variable. Conforming types may optionally guarantee atomicity.\n+\t///\n+\t/// Returns the result of the action.\n+\tfunc withValue<Result>(@noescape action: Value throws -> Result) rethrows -> Result","path":"ReactiveCocoa/Swift/Property.swift","position":22,"original_position":20,"commit_id":"e9903d8c85c9d483220d3a1e7dac6b2daba4142b","original_commit_id":"30d75ae6fec347f6e0f01e0d24a4d55d9c97b56b","user":{"login":"mdiep","id":1302,"avatar_url":"https://avatars.githubusercontent.com/u/1302?v=3","gravatar_id":"","url":"https://api.github.com/users/mdiep","html_url":"https://github.com/mdiep","followers_url":"https://api.github.com/users/mdiep/followers","following_url":"https://api.github.com/users/mdiep/following{/other_user}","gists_url":"https://api.github.com/users/mdiep/gists{/gist_id}","starred_url":"https://api.github.com/users/mdiep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdiep/subscriptions","organizations_url":"https://api.github.com/users/mdiep/orgs","repos_url":"https://api.github.com/users/mdiep/repos","events_url":"https://api.github.com/users/mdiep/events{/privacy}","received_events_url":"https://api.github.com/users/mdiep/received_events","type":"User","site_admin":false},"body":"But none of the property implement locking, so this is unneeded.","created_at":"2016-05-21T15:57:59Z","updated_at":"2016-05-21T15:57:59Z","html_url":"https://github.com/ReactiveCocoa/ReactiveCocoa/pull/2911#discussion_r64136430","pull_request_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/pulls/2911","_links":{"self":{"href":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/pulls/comments/64136430"},"html":{"href":"https://github.com/ReactiveCocoa/ReactiveCocoa/pull/2911#discussion_r64136430"},"pull_request":{"href":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/pulls/2911"}}},"pull_request":{"url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/pulls/2911","id":70698611,"html_url":"https://github.com/ReactiveCocoa/ReactiveCocoa/pull/2911","diff_url":"https://github.com/ReactiveCocoa/ReactiveCocoa/pull/2911.diff","patch_url":"https://github.com/ReactiveCocoa/ReactiveCocoa/pull/2911.patch","issue_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2911","number":2911,"state":"open","locked":false,"title":"Property composition and enhancements","user":{"login":"andersio","id":11806295,"avatar_url":"https://avatars.githubusercontent.com/u/11806295?v=3","gravatar_id":"","url":"https://api.github.com/users/andersio","html_url":"https://github.com/andersio","followers_url":"https://api.github.com/users/andersio/followers","following_url":"https://api.github.com/users/andersio/following{/other_user}","gists_url":"https://api.github.com/users/andersio/gists{/gist_id}","starred_url":"https://api.github.com/users/andersio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andersio/subscriptions","organizations_url":"https://api.github.com/users/andersio/orgs","repos_url":"https://api.github.com/users/andersio/repos","events_url":"https://api.github.com/users/andersio/events{/privacy}","received_events_url":"https://api.github.com/users/andersio/received_events","type":"User","site_admin":false},"body":"Here is an implementation of the #2841 proposal, seeking for your comments.\r\nSwift 3.0 is not required.\r\n\r\n#### Objective\r\nThis PR aims to introduce new composition operators on `PropertyType`.\r\n\r\nOn the other hand, `AnyMutableProperty` is introduced for users who would like to build higher level constructs that operate on the `MutablePropertyType` abstraction. An example would be two-way bindings between two `MutablePropertyType`s.\r\n\r\n#### Implementation\r\nThis PR carries breaking changes to those who have custom implementations of the `PropertyType` protocols.\r\n\r\n##### Type-erasing wrappers\r\n1. `AnyProperty` now uses a private, type erasing box.\r\n2. Passing-through `AnyProperty`s now complete its producer and signal when it has deinitialised.\r\n3. A new type erased wrapper `AnyMutableProperty` for `MutablePropertyType` conforming types.\r\n\r\n##### Protocols\r\n4. Introduce `withValue(action:)` and `modify(action:)` to the corresponding protocols.\r\n5. Make `value` and `swap(newValue:)` become a shorthand of (2) provided by the protocol extensions.\r\n6. Adapted all standard Property types to the aforementioned changes.\r\n\r\n##### Property Composition\r\n1. New combining operators: `combineLatest` and `zip`\r\n2. New value operators: `combinePrevious`, `skipRepeats` and `uniqueValues`\r\n3. New flattening operators: `flattenLatest` and `flatMapLatest`\r\n\r\n##### Miscellaneous\r\n1. Separated the `DynamicProperty` tests from the rest of the PropertySpec. \r\n2. Reorganised the `Property.swift`, with protocols & protocol extensions at the top, followed by implementations, bindings and finally the private utility classes.\r\n\r\n#### Caveats\r\n##### Why are closures replaced by type erasing boxes?\r\nThe current closure approach cannot be expressed non-escaping blocks and rethrowing functions in Swift 2.2 so far, and Swift 3 has tackled only one of them so far. Without these, `withValue` and `modify` cannot be brought to the protocols.\r\n\r\nIn the future (post Swift 3.0), these boxes should be replaceable by generic typealiases of a generalized existential without breaking any user code. Say we might have a `typealias AnyProperty<Value> = Any<PropertyType where .Value == Value>` in the future. :-]\r\n\r\n##### Why should the lifetime of the producer and signal of an passing-through `AnyProperty` change?\r\nThe passing-through `AnyProperty` and `DynamicProperty` are currently the exceptions to the defined contract. Specifically, the producer of `PropertyType` is *said* to *complete when the instance has deinitialised*. But the lifetime of the producer and signal of an `AnyProperty` **in reality** bound to its wrapped property.\r\n\r\nWhile AFAIK there is no report on this causing troubles, this might still lead to confusion since: (1) the producer- and signal-sourced `AnyProperty`s do not have such behavior; and (2) user may expect the producer/signal of such property to terminate based on the PropertyType contract, but experience something else **if** the wrapped property has a different lifetime.\r\n\r\nTo fix this inconsistency, the type-erasing box has its internal deinitialization signal applied to its wrapping producer and signal (with the `takeUntil` operator).\r\n\r\n##### Retaining source properties\r\nThe composed property retains their source properties. This is essential, since if we do not do so, the intermediate properties of a chained composition would be deallocated, and consequently propagate a terminating event to the end of the chain after exiting the calling scope.\r\n\r\n-\r\nEdited on 21 May 2016","created_at":"2016-05-19T13:57:57Z","updated_at":"2016-05-21T15:57:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"578555d8da4d5ce7f50826ab812836b489cfb651","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/pulls/2911/commits","review_comments_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/pulls/2911/comments","review_comment_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2911/comments","statuses_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/statuses/e9903d8c85c9d483220d3a1e7dac6b2daba4142b","head":{"label":"andersio:property-v2","ref":"property-v2","sha":"e9903d8c85c9d483220d3a1e7dac6b2daba4142b","user":{"login":"andersio","id":11806295,"avatar_url":"https://avatars.githubusercontent.com/u/11806295?v=3","gravatar_id":"","url":"https://api.github.com/users/andersio","html_url":"https://github.com/andersio","followers_url":"https://api.github.com/users/andersio/followers","following_url":"https://api.github.com/users/andersio/following{/other_user}","gists_url":"https://api.github.com/users/andersio/gists{/gist_id}","starred_url":"https://api.github.com/users/andersio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andersio/subscriptions","organizations_url":"https://api.github.com/users/andersio/orgs","repos_url":"https://api.github.com/users/andersio/repos","events_url":"https://api.github.com/users/andersio/events{/privacy}","received_events_url":"https://api.github.com/users/andersio/received_events","type":"User","site_admin":false},"repo":{"id":47269531,"name":"ReactiveCocoa","full_name":"andersio/ReactiveCocoa","owner":{"login":"andersio","id":11806295,"avatar_url":"https://avatars.githubusercontent.com/u/11806295?v=3","gravatar_id":"","url":"https://api.github.com/users/andersio","html_url":"https://github.com/andersio","followers_url":"https://api.github.com/users/andersio/followers","following_url":"https://api.github.com/users/andersio/following{/other_user}","gists_url":"https://api.github.com/users/andersio/gists{/gist_id}","starred_url":"https://api.github.com/users/andersio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andersio/subscriptions","organizations_url":"https://api.github.com/users/andersio/orgs","repos_url":"https://api.github.com/users/andersio/repos","events_url":"https://api.github.com/users/andersio/events{/privacy}","received_events_url":"https://api.github.com/users/andersio/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andersio/ReactiveCocoa","description":"Streams of values over time","fork":true,"url":"https://api.github.com/repos/andersio/ReactiveCocoa","forks_url":"https://api.github.com/repos/andersio/ReactiveCocoa/forks","keys_url":"https://api.github.com/repos/andersio/ReactiveCocoa/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andersio/ReactiveCocoa/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andersio/ReactiveCocoa/teams","hooks_url":"https://api.github.com/repos/andersio/ReactiveCocoa/hooks","issue_events_url":"https://api.github.com/repos/andersio/ReactiveCocoa/issues/events{/number}","events_url":"https://api.github.com/repos/andersio/ReactiveCocoa/events","assignees_url":"https://api.github.com/repos/andersio/ReactiveCocoa/assignees{/user}","branches_url":"https://api.github.com/repos/andersio/ReactiveCocoa/branches{/branch}","tags_url":"https://api.github.com/repos/andersio/ReactiveCocoa/tags","blobs_url":"https://api.github.com/repos/andersio/ReactiveCocoa/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andersio/ReactiveCocoa/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andersio/ReactiveCocoa/git/refs{/sha}","trees_url":"https://api.github.com/repos/andersio/ReactiveCocoa/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andersio/ReactiveCocoa/statuses/{sha}","languages_url":"https://api.github.com/repos/andersio/ReactiveCocoa/languages","stargazers_url":"https://api.github.com/repos/andersio/ReactiveCocoa/stargazers","contributors_url":"https://api.github.com/repos/andersio/ReactiveCocoa/contributors","subscribers_url":"https://api.github.com/repos/andersio/ReactiveCocoa/subscribers","subscription_url":"https://api.github.com/repos/andersio/ReactiveCocoa/subscription","commits_url":"https://api.github.com/repos/andersio/ReactiveCocoa/commits{/sha}","git_commits_url":"https://api.github.com/repos/andersio/ReactiveCocoa/git/commits{/sha}","comments_url":"https://api.github.com/repos/andersio/ReactiveCocoa/comments{/number}","issue_comment_url":"https://api.github.com/repos/andersio/ReactiveCocoa/issues/comments{/number}","contents_url":"https://api.github.com/repos/andersio/ReactiveCocoa/contents/{+path}","compare_url":"https://api.github.com/repos/andersio/ReactiveCocoa/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andersio/ReactiveCocoa/merges","archive_url":"https://api.github.com/repos/andersio/ReactiveCocoa/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andersio/ReactiveCocoa/downloads","issues_url":"https://api.github.com/repos/andersio/ReactiveCocoa/issues{/number}","pulls_url":"https://api.github.com/repos/andersio/ReactiveCocoa/pulls{/number}","milestones_url":"https://api.github.com/repos/andersio/ReactiveCocoa/milestones{/number}","notifications_url":"https://api.github.com/repos/andersio/ReactiveCocoa/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andersio/ReactiveCocoa/labels{/name}","releases_url":"https://api.github.com/repos/andersio/ReactiveCocoa/releases{/id}","deployments_url":"https://api.github.com/repos/andersio/ReactiveCocoa/deployments","created_at":"2015-12-02T15:21:14Z","updated_at":"2016-03-21T15:44:00Z","pushed_at":"2016-05-21T15:04:35Z","git_url":"git://github.com/andersio/ReactiveCocoa.git","ssh_url":"git@github.com:andersio/ReactiveCocoa.git","clone_url":"https://github.com/andersio/ReactiveCocoa.git","svn_url":"https://github.com/andersio/ReactiveCocoa","homepage":"","size":16055,"stargazers_count":0,"watchers_count":0,"language":"Objective-C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"ReactiveCocoa:master","ref":"master","sha":"428f1fbe49b1dbec92327ae57dad95625e946272","user":{"login":"ReactiveCocoa","id":3422977,"avatar_url":"https://avatars.githubusercontent.com/u/3422977?v=3","gravatar_id":"","url":"https://api.github.com/users/ReactiveCocoa","html_url":"https://github.com/ReactiveCocoa","followers_url":"https://api.github.com/users/ReactiveCocoa/followers","following_url":"https://api.github.com/users/ReactiveCocoa/following{/other_user}","gists_url":"https://api.github.com/users/ReactiveCocoa/gists{/gist_id}","starred_url":"https://api.github.com/users/ReactiveCocoa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ReactiveCocoa/subscriptions","organizations_url":"https://api.github.com/users/ReactiveCocoa/orgs","repos_url":"https://api.github.com/users/ReactiveCocoa/repos","events_url":"https://api.github.com/users/ReactiveCocoa/events{/privacy}","received_events_url":"https://api.github.com/users/ReactiveCocoa/received_events","type":"Organization","site_admin":false},"repo":{"id":3606624,"name":"ReactiveCocoa","full_name":"ReactiveCocoa/ReactiveCocoa","owner":{"login":"ReactiveCocoa","id":3422977,"avatar_url":"https://avatars.githubusercontent.com/u/3422977?v=3","gravatar_id":"","url":"https://api.github.com/users/ReactiveCocoa","html_url":"https://github.com/ReactiveCocoa","followers_url":"https://api.github.com/users/ReactiveCocoa/followers","following_url":"https://api.github.com/users/ReactiveCocoa/following{/other_user}","gists_url":"https://api.github.com/users/ReactiveCocoa/gists{/gist_id}","starred_url":"https://api.github.com/users/ReactiveCocoa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ReactiveCocoa/subscriptions","organizations_url":"https://api.github.com/users/ReactiveCocoa/orgs","repos_url":"https://api.github.com/users/ReactiveCocoa/repos","events_url":"https://api.github.com/users/ReactiveCocoa/events{/privacy}","received_events_url":"https://api.github.com/users/ReactiveCocoa/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ReactiveCocoa/ReactiveCocoa","description":"Streams of values over time","fork":false,"url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa","forks_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/forks","keys_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/teams","hooks_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/hooks","issue_events_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/events{/number}","events_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/events","assignees_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/assignees{/user}","branches_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/branches{/branch}","tags_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/tags","blobs_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/git/refs{/sha}","trees_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/statuses/{sha}","languages_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/languages","stargazers_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/stargazers","contributors_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/contributors","subscribers_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/subscribers","subscription_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/subscription","commits_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/commits{/sha}","git_commits_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/git/commits{/sha}","comments_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/comments{/number}","issue_comment_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/comments{/number}","contents_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/contents/{+path}","compare_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/merges","archive_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/downloads","issues_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues{/number}","pulls_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/pulls{/number}","milestones_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/milestones{/number}","notifications_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/labels{/name}","releases_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/releases{/id}","deployments_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/deployments","created_at":"2012-03-02T22:11:24Z","updated_at":"2016-05-21T12:55:34Z","pushed_at":"2016-05-21T15:45:18Z","git_url":"git://github.com/ReactiveCocoa/ReactiveCocoa.git","ssh_url":"git@github.com:ReactiveCocoa/ReactiveCocoa.git","clone_url":"https://github.com/ReactiveCocoa/ReactiveCocoa.git","svn_url":"https://github.com/ReactiveCocoa/ReactiveCocoa","homepage":"","size":24639,"stargazers_count":13954,"watchers_count":13954,"language":"Objective-C","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2562,"mirror_url":null,"open_issues_count":32,"forks":2562,"open_issues":32,"watchers":13954,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/pulls/2911"},"html":{"href":"https://github.com/ReactiveCocoa/ReactiveCocoa/pull/2911"},"issue":{"href":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2911"},"comments":{"href":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2911/comments"},"review_comments":{"href":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/pulls/2911/comments"},"review_comment":{"href":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/pulls/2911/commits"},"statuses":{"href":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/statuses/e9903d8c85c9d483220d3a1e7dac6b2daba4142b"}}}}
{"actor":{"display_login":"mdiep"}}