{"action":"closed","issue":{"url":"https://api.github.com/repos/Reactive-Extensions/RxJS/issues/863","labels_url":"https://api.github.com/repos/Reactive-Extensions/RxJS/issues/863/labels{/name}","comments_url":"https://api.github.com/repos/Reactive-Extensions/RxJS/issues/863/comments","events_url":"https://api.github.com/repos/Reactive-Extensions/RxJS/issues/863/events","html_url":"https://github.com/Reactive-Extensions/RxJS/issues/863","id":101891303,"number":863,"title":"Alternative for ES7 bind operator","user":{"login":"xgrommx","id":1499594,"avatar_url":"https://avatars.githubusercontent.com/u/1499594?v=3","gravatar_id":"","url":"https://api.github.com/users/xgrommx","html_url":"https://github.com/xgrommx","followers_url":"https://api.github.com/users/xgrommx/followers","following_url":"https://api.github.com/users/xgrommx/following{/other_user}","gists_url":"https://api.github.com/users/xgrommx/gists{/gist_id}","starred_url":"https://api.github.com/users/xgrommx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xgrommx/subscriptions","organizations_url":"https://api.github.com/users/xgrommx/orgs","repos_url":"https://api.github.com/users/xgrommx/repos","events_url":"https://api.github.com/users/xgrommx/events{/privacy}","received_events_url":"https://api.github.com/users/xgrommx/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":24,"created_at":"2015-08-19T13:19:32Z","updated_at":"2015-09-16T19:04:57Z","closed_at":"2015-09-16T19:04:57Z","body":"Hi @mattpodwysocki. I have some experiment with ES7 [`bind`](https://github.com/zenparsing/es-function-bind) operator. With help this operator we can:\r\n\r\n```js\r\nconst {Observable, Subject} = Rx;\r\n\r\nconst subj = new Subject();\r\nconst obs = subj.asObservable();\r\nconst customOp = (mapper) => this.map(mapper);\r\n\r\nobs.map(x => typeof x !== 'undefined')::customOp(x => `${x} custom!`).subscribe(::console.log);\r\n\r\nsubj.onNext(20);\r\n```\r\nThis is awesome, but this specification isn't approved now. I have a small alternative for this approach:\r\n\r\n```js\r\nconst {Observable, Subject} = Rx;\r\nconst {curry} = R; // this is Ramda\r\n\r\nconst subj = new Subject();\r\nconst obs = subj.asObservable();\r\n\r\nconst customOp = curry((mapper, self) => self.map(mapper)); // Use currying instead of two callbacks.\r\n\r\nObservable.bind = (func) => func(this);\r\n\r\nobs.map(x => typeof x !== 'undefined').bind(customOp(x => `${x} custom!`)).subscribe(::console.log);\r\n\r\nsubj.onNext(20);\r\n```\r\nWhat do you think about it? Maybe you have more better ideas."}}