{"action":"created","issue":{"url":"https://api.github.com/repos/stampit-org/stamp-specification/issues/70","repository_url":"https://api.github.com/repos/stampit-org/stamp-specification","labels_url":"https://api.github.com/repos/stampit-org/stamp-specification/issues/70/labels{/name}","comments_url":"https://api.github.com/repos/stampit-org/stamp-specification/issues/70/comments","events_url":"https://api.github.com/repos/stampit-org/stamp-specification/issues/70/events","html_url":"https://github.com/stampit-org/stamp-specification/issues/70","id":134756611,"number":70,"title":"Remove identical intializers","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":[{"url":"https://api.github.com/repos/stampit-org/stamp-specification/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/stampit-org/stamp-specification/labels/proposal","name":"proposal","color":"fbca04"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":43,"created_at":"2016-02-19T02:46:54Z","updated_at":"2016-08-01T19:08:52Z","closed_at":"2016-05-21T12:22:19Z","body":"This is not the first time I'm having the following problem.\r\n\r\n* Stamp1 have a CPU expensive \"init\" function.\r\n* Stamp2 is using Stamp1 (`Stamp2 = compose(Stamp1, ...)`\r\n* Stamp3 is using Stamp1 to (`Stamp3 = compose(Stamp1, ...)`\r\n* Stamp4 is using Stamp1 and Stamp2 (`Stamp4 = compose(Stamp1, Stamp2, ...)`\r\n* Finally, Stamp5 is using all of them: `Stamp5 = compose(Stamp1, Stamp2, Stamp3, Stamp4, ...)`\r\nThe problem: the expensive \"init\" is called **five times**. This is my production example.\r\n\r\nProposal: remove duplicate `init` functions from the `.initializers[]` array. \r\n\r\nThe change will touch [this single line](https://github.com/stampit-org/stamp-specification/blob/master/examples/compose.js#L60): \r\n```js\r\ndstDescriptor.initializers = _.uniq(...\r\n```\r\n\r\nThe lodash \"uniq\" function removes the same items form the back. In other words:\r\n```\r\n_.uniq([1, 2, 3, 1]) ==> [ 1, 2, 3 ]\r\n```\r\n\r\nAny caveats I'm missing here?"},"comment":{"url":"https://api.github.com/repos/stampit-org/stamp-specification/issues/comments/236676668","html_url":"https://github.com/stampit-org/stamp-specification/issues/70#issuecomment-236676668","issue_url":"https://api.github.com/repos/stampit-org/stamp-specification/issues/70","id":236676668,"user":{"login":"FredyC","id":1096340,"avatar_url":"https://avatars.githubusercontent.com/u/1096340?v=3","gravatar_id":"","url":"https://api.github.com/users/FredyC","html_url":"https://github.com/FredyC","followers_url":"https://api.github.com/users/FredyC/followers","following_url":"https://api.github.com/users/FredyC/following{/other_user}","gists_url":"https://api.github.com/users/FredyC/gists{/gist_id}","starred_url":"https://api.github.com/users/FredyC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FredyC/subscriptions","organizations_url":"https://api.github.com/users/FredyC/orgs","repos_url":"https://api.github.com/users/FredyC/repos","events_url":"https://api.github.com/users/FredyC/events{/privacy}","received_events_url":"https://api.github.com/users/FredyC/received_events","type":"User","site_admin":false},"created_at":"2016-08-01T19:08:52Z","updated_at":"2016-08-01T19:08:52Z","body":"Well I must I got bit lost in here what we are actually trying to solve by all this. I mean trying took for different approach instead of deduplicating initiatilizers out of the box, that's obvious. However things like `initOnce` surely just adds confusion uncessarilly.\r\n\r\n> That's fine, but I'm trying to get to why we have this problem in the first place.\r\n\r\nSorry if I am wrong, but have you written some complex stamps on your own? As you have stated [here](https://github.com/stampit-org/stamp-specification/issues/70#issuecomment-235062017), you are deliberately avoiding to compose stamp multiple times over. Perhaps if you start avoiding it, you will discover the need for deduping. I think it's nice feature of stamps, for OOP newcomer it looks like long wanted multiple inheritance."}}
{"actor":{"display_login":"FredyC"}}