{"action":"created","issue":{"url":"https://api.github.com/repos/async-interop/awaitable/issues/10","repository_url":"https://api.github.com/repos/async-interop/awaitable","labels_url":"https://api.github.com/repos/async-interop/awaitable/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/async-interop/awaitable/issues/10/comments","events_url":"https://api.github.com/repos/async-interop/awaitable/issues/10/events","html_url":"https://github.com/async-interop/awaitable/issues/10","id":161479866,"number":10,"title":"Memory leaks with combinator functions","user":{"login":"joshdifabio","id":5609851,"avatar_url":"https://avatars.githubusercontent.com/u/5609851?v=3","gravatar_id":"","url":"https://api.github.com/users/joshdifabio","html_url":"https://github.com/joshdifabio","followers_url":"https://api.github.com/users/joshdifabio/followers","following_url":"https://api.github.com/users/joshdifabio/following{/other_user}","gists_url":"https://api.github.com/users/joshdifabio/gists{/gist_id}","starred_url":"https://api.github.com/users/joshdifabio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshdifabio/subscriptions","organizations_url":"https://api.github.com/users/joshdifabio/orgs","repos_url":"https://api.github.com/users/joshdifabio/repos","events_url":"https://api.github.com/users/joshdifabio/events{/privacy}","received_events_url":"https://api.github.com/users/joshdifabio/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-06-21T16:17:17Z","updated_at":"2016-06-21T16:56:03Z","closed_at":null,"body":"I have [uploaded a gist](https://gist.github.com/joshdifabio/8d61ddba2539677680892232bbd49067) which shows a problem I've encountered recently when using promises and combinators: specifically, using a combinator function (particularly `first()`/`race()`/`any()`) will cause redundant resolver callbacks to remain attached to whichever promises do not 'win' the race to resolve the combined promise. The current `Awaitable` interface does not provide any mechanism to overcome this issue (e.g. some kind of `cancel()` or `dispose()` method). What do others think about this issue?\r\n\r\nI don't personally think combinators should implicitly _abort_ 'losing' promises (which is what `cancel()` sometimes means) but I do think it might be nice to have some kind of `dispose()` method:\r\n\r\n```php\r\ninterface Awaitable\r\n{\r\n    public function when(callback $onResolved): Disposable;\r\n}\r\n\r\ninterface Disposable\r\n{\r\n    /** Inform the awaitable that you no longer care about its result and it can remove your callback **/\r\n    public function dispose();\r\n}\r\n```\r\n\r\nI'm guessing people will be against such a change, but it's come up for me a couple of times so I'm interested to hear people's thoughts."},"comment":{"url":"https://api.github.com/repos/async-interop/awaitable/issues/comments/227502800","html_url":"https://github.com/async-interop/awaitable/issues/10#issuecomment-227502800","issue_url":"https://api.github.com/repos/async-interop/awaitable/issues/10","id":227502800,"user":{"login":"kelunik","id":2743004,"avatar_url":"https://avatars.githubusercontent.com/u/2743004?v=3","gravatar_id":"","url":"https://api.github.com/users/kelunik","html_url":"https://github.com/kelunik","followers_url":"https://api.github.com/users/kelunik/followers","following_url":"https://api.github.com/users/kelunik/following{/other_user}","gists_url":"https://api.github.com/users/kelunik/gists{/gist_id}","starred_url":"https://api.github.com/users/kelunik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kelunik/subscriptions","organizations_url":"https://api.github.com/users/kelunik/orgs","repos_url":"https://api.github.com/users/kelunik/repos","events_url":"https://api.github.com/users/kelunik/events{/privacy}","received_events_url":"https://api.github.com/users/kelunik/received_events","type":"User","site_admin":false},"created_at":"2016-06-21T16:56:03Z","updated_at":"2016-06-21T16:56:03Z","body":"Where's the memory leak now?"}}
{"actor":{"display_login":"kelunik"}}