{"action":"created","issue":{"url":"https://api.github.com/repos/Reactive-Extensions/Rx.NET/issues/436","repository_url":"https://api.github.com/repos/Reactive-Extensions/Rx.NET","labels_url":"https://api.github.com/repos/Reactive-Extensions/Rx.NET/issues/436/labels{/name}","comments_url":"https://api.github.com/repos/Reactive-Extensions/Rx.NET/issues/436/comments","events_url":"https://api.github.com/repos/Reactive-Extensions/Rx.NET/issues/436/events","html_url":"https://github.com/Reactive-Extensions/Rx.NET/pull/436","id":261917913,"number":436,"title":"Add a new 'partition' operator to split a sequence based on a given predicate","user":{"login":"spencercw","id":595813,"avatar_url":"https://avatars2.githubusercontent.com/u/595813?v=4","gravatar_id":"","url":"https://api.github.com/users/spencercw","html_url":"https://github.com/spencercw","followers_url":"https://api.github.com/users/spencercw/followers","following_url":"https://api.github.com/users/spencercw/following{/other_user}","gists_url":"https://api.github.com/users/spencercw/gists{/gist_id}","starred_url":"https://api.github.com/users/spencercw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spencercw/subscriptions","organizations_url":"https://api.github.com/users/spencercw/orgs","repos_url":"https://api.github.com/users/spencercw/repos","events_url":"https://api.github.com/users/spencercw/events{/privacy}","received_events_url":"https://api.github.com/users/spencercw/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2017-10-01T13:57:24Z","updated_at":"2017-10-01T18:39:08Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/Reactive-Extensions/Rx.NET/pulls/436","html_url":"https://github.com/Reactive-Extensions/Rx.NET/pull/436","diff_url":"https://github.com/Reactive-Extensions/Rx.NET/pull/436.diff","patch_url":"https://github.com/Reactive-Extensions/Rx.NET/pull/436.patch"},"body":"Inspired by the equivalents from F# and RxJS, this is a new Linq operator which allows a sequence to be split in two based on some predicate. This is useful as an alternative to `Where` in case you are interested in both the true and false branches and want to process them independently.\r\n\r\nExample usage:\r\n\r\n```\r\nvar (evens, odds) = observable.Partition(x => x % 2 == 0);\r\nevens.Subscribe(x => Console.WriteLine(\"Even: \" + x));\r\nodds.Subscribe(x => Console.WriteLine(\"Odd: \" + x));\r\n```\r\n\r\nThis is roughly equivalent to the below. The benefits being that the sequence is only evaluated once (so no need to convert the sequence into a connectable), and the predicate only needs to be evaluated once for each element.\r\n\r\n```\r\nvar numbers = observable.Publish();\r\nnumbers.Where(x => x % 2 == 0).Subscribe(x => Console.WriteLine(\"Even: \" + x));\r\nnumbers.Where(x => x % 2 != 0).Subscribe(x => Console.WriteLine(\"Odd: \" + x));\r\nnumbers.Connect();\r\n```\r\n\r\nI think I need to do something to `Qbservable`, but I'm not sure what exactly. The HomoIcon tool seems to be a bit broken, at least on develop. The `Qbservable_Observable_Parity` test is currently failing because `Partition` is missing.\r\n\r\nThis is my first time trying to do anything in the Rx.NET codebase so there's a decent chance I've messed it up one way or another. Any feedback would be welcome."},"comment":{"url":"https://api.github.com/repos/Reactive-Extensions/Rx.NET/issues/comments/333397091","html_url":"https://github.com/Reactive-Extensions/Rx.NET/pull/436#issuecomment-333397091","issue_url":"https://api.github.com/repos/Reactive-Extensions/Rx.NET/issues/436","id":333397091,"user":{"login":"RxDave","id":8392258,"avatar_url":"https://avatars0.githubusercontent.com/u/8392258?v=4","gravatar_id":"","url":"https://api.github.com/users/RxDave","html_url":"https://github.com/RxDave","followers_url":"https://api.github.com/users/RxDave/followers","following_url":"https://api.github.com/users/RxDave/following{/other_user}","gists_url":"https://api.github.com/users/RxDave/gists{/gist_id}","starred_url":"https://api.github.com/users/RxDave/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RxDave/subscriptions","organizations_url":"https://api.github.com/users/RxDave/orgs","repos_url":"https://api.github.com/users/RxDave/repos","events_url":"https://api.github.com/users/RxDave/events{/privacy}","received_events_url":"https://api.github.com/users/RxDave/received_events","type":"User","site_admin":false},"created_at":"2017-10-01T18:39:08Z","updated_at":"2017-10-01T18:39:08Z","author_association":"CONTRIBUTOR","body":"You may still run into problems if you require both. For example, it will break this scenario: \r\n\r\n    evens.Subscribe(x => Console.WriteLine(\"Even: \" + x));\r\n    odds.Subscribe(x => Console.WriteLine(\"Odd: \" + x));\r\n    evensPlus1.Subscribe(x => Console.WriteLine(\"Even: \" + x + 1));\r\n\r\nWhen _odds_ subscribes, if a connection is made to the source observable, then _evensPlus1_ may miss notifications.\r\n\r\nThe solution of course is to `Publish` again! But if you just use `Publish` in the first place, then you have full control, without the overhead of multiple calls to `Publish`.\r\n\r\nOf course, an operator like `Partition` might be useful is some scenarios, but I don't think it makes sense as a standard query operator. Or at least, if it's going to be a standard query operator, then it must expose the connectability of the source to the caller, either via an _out_ parameter or another item in the tuple, as in my example.\r\n\r\nI don't see it as a simple if-then-else operation. It's primarily a temperature conversion operation with some additional semantics. In your case, it's filter semantics, but perhaps the same case could be made for projection or aggregation as well.\r\n"}}
{"actor":{"display_login":"RxDave"}}