{"action":"created","issue":{"url":"https://api.github.com/repos/rtfeldman/seamless-immutable/issues/48","labels_url":"https://api.github.com/repos/rtfeldman/seamless-immutable/issues/48/labels{/name}","comments_url":"https://api.github.com/repos/rtfeldman/seamless-immutable/issues/48/comments","events_url":"https://api.github.com/repos/rtfeldman/seamless-immutable/issues/48/events","html_url":"https://github.com/rtfeldman/seamless-immutable/issues/48","id":93637726,"number":48,"title":"Immutable.js like Records","user":{"login":"virajsanghvi","id":1366272,"avatar_url":"https://avatars.githubusercontent.com/u/1366272?v=3","gravatar_id":"","url":"https://api.github.com/users/virajsanghvi","html_url":"https://github.com/virajsanghvi","followers_url":"https://api.github.com/users/virajsanghvi/followers","following_url":"https://api.github.com/users/virajsanghvi/following{/other_user}","gists_url":"https://api.github.com/users/virajsanghvi/gists{/gist_id}","starred_url":"https://api.github.com/users/virajsanghvi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/virajsanghvi/subscriptions","organizations_url":"https://api.github.com/users/virajsanghvi/orgs","repos_url":"https://api.github.com/users/virajsanghvi/repos","events_url":"https://api.github.com/users/virajsanghvi/events{/privacy}","received_events_url":"https://api.github.com/users/virajsanghvi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-07-07T21:51:26Z","updated_at":"2015-07-21T01:14:39Z","closed_at":null,"body":"I'd like to be able to use this library to approximate Immutable.js Records: https://facebook.github.io/immutable-js/docs/#/Record\r\n\r\nThe benefits I see from this are helper functions (e.g. calculated fields on a data object- ```getName()``` on an ```Immutable({firsName: ..., lastName: ...})```, defaulting fields, and validation.\r\n\r\nFrom #25, I can see you've chosen not to support object prototypes by default, but I was wondering if there was a way to opt into its use. Looking at the code, I couldn't find a simple solution for this. \r\n\r\nDo you have suggestions on how this type of functionality could be added, or potential hooks to enable the usecases above (defaulting might be the trickiest, but the others I feel could be handled by methods on the object)?\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/rtfeldman/seamless-immutable/issues/comments/123120629","html_url":"https://github.com/rtfeldman/seamless-immutable/issues/48#issuecomment-123120629","issue_url":"https://api.github.com/repos/rtfeldman/seamless-immutable/issues/48","id":123120629,"user":{"login":"rtfeldman","id":1094080,"avatar_url":"https://avatars.githubusercontent.com/u/1094080?v=3","gravatar_id":"","url":"https://api.github.com/users/rtfeldman","html_url":"https://github.com/rtfeldman","followers_url":"https://api.github.com/users/rtfeldman/followers","following_url":"https://api.github.com/users/rtfeldman/following{/other_user}","gists_url":"https://api.github.com/users/rtfeldman/gists{/gist_id}","starred_url":"https://api.github.com/users/rtfeldman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rtfeldman/subscriptions","organizations_url":"https://api.github.com/users/rtfeldman/orgs","repos_url":"https://api.github.com/users/rtfeldman/repos","events_url":"https://api.github.com/users/rtfeldman/events{/privacy}","received_events_url":"https://api.github.com/users/rtfeldman/received_events","type":"User","site_admin":false},"created_at":"2015-07-21T01:14:39Z","updated_at":"2015-07-21T01:14:39Z","body":"I think a cleaner approach would be:\r\n\r\n1. Have `Immutable` accept a second argument for `options`, like `merge` does (this would be a breaking change, as currently it assumes if it gets multiple arguments you want an array; I'm fine with that breaking hange)\r\n2. If it gets a second argument of `{prototype: foo`} then use `foo` as the prototype for the resulting object.\r\n3. Add a method `instantiateEmptyObject()` (in the same way the other custom methods are added) and have it either return `{}` if no prototype was specified, and `Object.create(options.prototype)` if one was specified.\r\n4. Have the various methods call `this.instantiateEmptyObject()` instead of just using `{}`\r\n\r\nThoughts?"}}