{"action":"created","issue":{"url":"https://api.github.com/repos/stampit-org/stamp-specification/issues/21","labels_url":"https://api.github.com/repos/stampit-org/stamp-specification/issues/21/labels{/name}","comments_url":"https://api.github.com/repos/stampit-org/stamp-specification/issues/21/comments","events_url":"https://api.github.com/repos/stampit-org/stamp-specification/issues/21/events","html_url":"https://github.com/stampit-org/stamp-specification/issues/21","id":102581134,"number":21,"title":"More control on composition","user":{"login":"koresar","id":1622575,"avatar_url":"https://avatars.githubusercontent.com/u/1622575?v=3","gravatar_id":"","url":"https://api.github.com/users/koresar","html_url":"https://github.com/koresar","followers_url":"https://api.github.com/users/koresar/followers","following_url":"https://api.github.com/users/koresar/following{/other_user}","gists_url":"https://api.github.com/users/koresar/gists{/gist_id}","starred_url":"https://api.github.com/users/koresar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koresar/subscriptions","organizations_url":"https://api.github.com/users/koresar/orgs","repos_url":"https://api.github.com/users/koresar/repos","events_url":"https://api.github.com/users/koresar/events{/privacy}","received_events_url":"https://api.github.com/users/koresar/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-08-23T02:22:32Z","updated_at":"2015-08-23T20:13:23Z","closed_at":null,"body":"I wish there was a feature when I, as a stamp author, can get access to both **left**, **right** and **resulting** stamps in a single context.\r\n\r\nFanasy code:\r\n```js\r\nconst CompositionControl = compose({\r\n  preCompose({left, right, result}) {\r\n    if (left.methods.foo && right.methods.foo) { // Dummy implementation, don't pay attention please\r\n      result.methods._foo1 = left.methods.foo;\r\n      result.methods._foo2 = right.methods.foo;\r\n      result.methods.foo = function(...args) { this._foo1(...args); this._foo2(...args); }\r\n    }\r\n  }\r\n});\r\n\r\nconst FooStamp = CompositionControl.compose({ methods: {\r\n  foo() { console.log('foo'); }\r\n}});\r\n\r\nconst BarStamp = compose({ methods: {\r\n  foo() { console.log('OVERRIDE'); }\r\n}});\r\n\r\nconst Final = compose(FooStamp, BarStamp);\r\n\r\nFinal(); // will print both \"foo\" and \"OVERRIDE\"\r\n```\r\n\r\nThis could be beneficial to handle/maintain/log collision issues.\r\n\r\nThoughts?"},"comment":{"url":"https://api.github.com/repos/stampit-org/stamp-specification/issues/comments/133916305","html_url":"https://github.com/stampit-org/stamp-specification/issues/21#issuecomment-133916305","issue_url":"https://api.github.com/repos/stampit-org/stamp-specification/issues/21","id":133916305,"user":{"login":"ericelliott","id":364727,"avatar_url":"https://avatars.githubusercontent.com/u/364727?v=3","gravatar_id":"","url":"https://api.github.com/users/ericelliott","html_url":"https://github.com/ericelliott","followers_url":"https://api.github.com/users/ericelliott/followers","following_url":"https://api.github.com/users/ericelliott/following{/other_user}","gists_url":"https://api.github.com/users/ericelliott/gists{/gist_id}","starred_url":"https://api.github.com/users/ericelliott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericelliott/subscriptions","organizations_url":"https://api.github.com/users/ericelliott/orgs","repos_url":"https://api.github.com/users/ericelliott/repos","events_url":"https://api.github.com/users/ericelliott/events{/privacy}","received_events_url":"https://api.github.com/users/ericelliott/received_events","type":"User","site_admin":false},"created_at":"2015-08-23T20:13:23Z","updated_at":"2015-08-23T20:13:23Z","body":"I'm not convinced this is needed at all. See, for instance:\r\n\r\n```js\r\nimport stampit from 'stampit'\r\nimport Sight from './sight'\r\nimport Sound from './sound'\r\n\r\nconst Senses = stampit().init(({ instance }) => {\r\n  const sight = Sight();\r\n  const sound = Sound();\r\n\r\n  instance.manifest = () => {\r\n    sight.manifest();\r\n    sound.manifest();\r\n  }\r\n\r\n  return instance;\r\n});\r\n```\r\n\r\nInitializers give you the power to compose multiple stamps in any way you want using the stamp API. If you need to do things that aren't supported by the default compose logic, you should do so in a stamp, not by adding complexity to the compose API.\r\n\r\nWe should show examples of how to do things like that using stamps in advanced examples."}}