{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/immutable-js/issues/227","labels_url":"https://api.github.com/repos/facebook/immutable-js/issues/227/labels{/name}","comments_url":"https://api.github.com/repos/facebook/immutable-js/issues/227/comments","events_url":"https://api.github.com/repos/facebook/immutable-js/issues/227/events","html_url":"https://github.com/facebook/immutable-js/pull/227","id":51012831,"number":227,"title":"Inherit from base types","user":{"login":"tgriesser","id":154748,"avatar_url":"https://avatars.githubusercontent.com/u/154748?v=3","gravatar_id":"","url":"https://api.github.com/users/tgriesser","html_url":"https://github.com/tgriesser","followers_url":"https://api.github.com/users/tgriesser/followers","following_url":"https://api.github.com/users/tgriesser/following{/other_user}","gists_url":"https://api.github.com/users/tgriesser/gists{/gist_id}","starred_url":"https://api.github.com/users/tgriesser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgriesser/subscriptions","organizations_url":"https://api.github.com/users/tgriesser/orgs","repos_url":"https://api.github.com/users/tgriesser/repos","events_url":"https://api.github.com/users/tgriesser/events{/privacy}","received_events_url":"https://api.github.com/users/tgriesser/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2014-12-04T18:51:41Z","updated_at":"2015-01-20T02:33:41Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/facebook/immutable-js/pulls/227","html_url":"https://github.com/facebook/immutable-js/pull/227","diff_url":"https://github.com/facebook/immutable-js/pull/227.diff","patch_url":"https://github.com/facebook/immutable-js/pull/227.patch"},"body":"Here's a first pass at making it possible to inherit from `Map`, `List`, `Set`, `OrderedMap`, etc.\r\n\r\nMostly putting this here for discussion, as there are probably a few ways to attack this one, but this seems to be working quite well in my preliminary use. It also has the benefit of eliminating `Object.create(MapPrototype)` in favor of `new Ctor`, which gives better inspection in the chrome console (and [potentially perf?](http://jsperf.com/obj-create-vs-new/4))\r\n\r\nThe inherited types must initially be constructed with `new`, and when inheriting via class style, it's necessary to return from the constructor:\r\n\r\n```js\r\nclass User extends Immutable.Map {\r\n  \r\n  constructor(value) {\r\n    return super(value)\r\n  }\r\n \r\n  fullName() {\r\n    return this.get('firstName') + ' ' + this.get('lastName');\r\n  }\r\n\r\n}\r\n```\r\n\r\nIf you think this looks good, I could beef up the tests a bit."},"comment":{"url":"https://api.github.com/repos/facebook/immutable-js/issues/comments/70595441","html_url":"https://github.com/facebook/immutable-js/pull/227#issuecomment-70595441","issue_url":"https://api.github.com/repos/facebook/immutable-js/issues/227","id":70595441,"user":{"login":"tgriesser","id":154748,"avatar_url":"https://avatars.githubusercontent.com/u/154748?v=3","gravatar_id":"","url":"https://api.github.com/users/tgriesser","html_url":"https://github.com/tgriesser","followers_url":"https://api.github.com/users/tgriesser/followers","following_url":"https://api.github.com/users/tgriesser/following{/other_user}","gists_url":"https://api.github.com/users/tgriesser/gists{/gist_id}","starred_url":"https://api.github.com/users/tgriesser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgriesser/subscriptions","organizations_url":"https://api.github.com/users/tgriesser/orgs","repos_url":"https://api.github.com/users/tgriesser/repos","events_url":"https://api.github.com/users/tgriesser/events{/privacy}","received_events_url":"https://api.github.com/users/tgriesser/received_events","type":"User","site_admin":false},"created_at":"2015-01-20T02:33:41Z","updated_at":"2015-01-20T02:33:41Z","body":"So I updated this to latest and ran that new `perf` suite, looks like this branch takes a pretty substantial hit ~50% or more on each of the tests. \r\n\r\nSo unfortunately this doesn't look like it's the best approach, though figuring out some way to do this eventually would be really cool - the ability to have custom types for `Maps`/`OrderedMaps` has proved quite convenient in our application."}}