{"action":"opened","issue":{"url":"https://api.github.com/repos/gcanti/tcomb/issues/127","labels_url":"https://api.github.com/repos/gcanti/tcomb/issues/127/labels{/name}","comments_url":"https://api.github.com/repos/gcanti/tcomb/issues/127/comments","events_url":"https://api.github.com/repos/gcanti/tcomb/issues/127/events","html_url":"https://github.com/gcanti/tcomb/issues/127","id":103442275,"number":127,"title":"Handling the \"update\" method for union","user":{"login":"jgoux","id":1443499,"avatar_url":"https://avatars.githubusercontent.com/u/1443499?v=3","gravatar_id":"","url":"https://api.github.com/users/jgoux","html_url":"https://github.com/jgoux","followers_url":"https://api.github.com/users/jgoux/followers","following_url":"https://api.github.com/users/jgoux/following{/other_user}","gists_url":"https://api.github.com/users/jgoux/gists{/gist_id}","starred_url":"https://api.github.com/users/jgoux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jgoux/subscriptions","organizations_url":"https://api.github.com/users/jgoux/orgs","repos_url":"https://api.github.com/users/jgoux/repos","events_url":"https://api.github.com/users/jgoux/events{/privacy}","received_events_url":"https://api.github.com/users/jgoux/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-08-27T06:58:52Z","updated_at":"2015-08-27T06:58:52Z","closed_at":null,"body":"Hello,\r\nif we call the \"update\" method on a union type, it throws a `undefined is not a function` error.\r\nFor this particular case, a default implementation of update could be implemented for union types, so it delegates to one of its underlying type based on the dispatch method.\r\nBased on the example I provided here https://github.com/gcanti/tcomb/issues/126 : \r\n```js\r\nconst TodoListAggregate.Command = union([AddTodo, EditTodo])\r\nTodoListAggregate.Command.dispatch(customDispatch)\r\nconst Command = union([TodoListAggregate.Command, AnotherAggregate.Command])\r\nconst command = Command(fooBar)\r\nconst enrichedCommand = Command.update(command, {\r\n    data: {meta: {\"$merge\": {date: new Date()}}}\r\n}) // use the internal dispatch to find the corresponding type, then call its update method\r\n```"}}