{"action":"created","issue":{"url":"https://api.github.com/repos/callemall/material-ui/issues/2957","repository_url":"https://api.github.com/repos/callemall/material-ui","labels_url":"https://api.github.com/repos/callemall/material-ui/issues/2957/labels{/name}","comments_url":"https://api.github.com/repos/callemall/material-ui/issues/2957/comments","events_url":"https://api.github.com/repos/callemall/material-ui/issues/2957/events","html_url":"https://github.com/callemall/material-ui/issues/2957","id":127045681,"number":2957,"title":"Standardization of Callback Signatures","user":{"login":"alitaheri","id":8528759,"avatar_url":"https://avatars.githubusercontent.com/u/8528759?v=3","gravatar_id":"","url":"https://api.github.com/users/alitaheri","html_url":"https://github.com/alitaheri","followers_url":"https://api.github.com/users/alitaheri/followers","following_url":"https://api.github.com/users/alitaheri/following{/other_user}","gists_url":"https://api.github.com/users/alitaheri/gists{/gist_id}","starred_url":"https://api.github.com/users/alitaheri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alitaheri/subscriptions","organizations_url":"https://api.github.com/users/alitaheri/orgs","repos_url":"https://api.github.com/users/alitaheri/repos","events_url":"https://api.github.com/users/alitaheri/events{/privacy}","received_events_url":"https://api.github.com/users/alitaheri/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/callemall/material-ui/labels/Core","name":"Core","color":"006b75"},{"url":"https://api.github.com/repos/callemall/material-ui/labels/Discussion","name":"Discussion","color":"bfdadc"},{"url":"https://api.github.com/repos/callemall/material-ui/labels/Umbrella","name":"Umbrella","color":"1a1a1a"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/callemall/material-ui/milestones/14","html_url":"https://github.com/callemall/material-ui/milestones/0.16.0%20Release","labels_url":"https://api.github.com/repos/callemall/material-ui/milestones/14/labels","id":1582007,"number":14,"title":"0.16.0 Release","description":"","creator":{"login":"alitaheri","id":8528759,"avatar_url":"https://avatars.githubusercontent.com/u/8528759?v=3","gravatar_id":"","url":"https://api.github.com/users/alitaheri","html_url":"https://github.com/alitaheri","followers_url":"https://api.github.com/users/alitaheri/followers","following_url":"https://api.github.com/users/alitaheri/following{/other_user}","gists_url":"https://api.github.com/users/alitaheri/gists{/gist_id}","starred_url":"https://api.github.com/users/alitaheri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alitaheri/subscriptions","organizations_url":"https://api.github.com/users/alitaheri/orgs","repos_url":"https://api.github.com/users/alitaheri/repos","events_url":"https://api.github.com/users/alitaheri/events{/privacy}","received_events_url":"https://api.github.com/users/alitaheri/received_events","type":"User","site_admin":false},"open_issues":26,"closed_issues":6,"state":"open","created_at":"2016-02-14T16:34:47Z","updated_at":"2016-06-15T07:37:00Z","due_on":null,"closed_at":null},"comments":21,"created_at":"2016-01-16T18:53:17Z","updated_at":"2016-06-17T16:59:58Z","closed_at":null,"body":"We need to discuss how will we standardize the callbacks that some component take in order to behave in a controllable fashion. But since the signature of the callback function they accept is different across components, many new comers get confused. \r\n\r\nTherefore, we have to come to a solution on this. \r\n\r\n### My proposal:\r\n\r\n1. Every controllable component should only be controlled via `value` and `onChange` props. No more `onRequestXxx`. \r\n\r\n2. the `value` must be as versatile as possible, if it make sense for it to be anything equatable with `===` then it should be marked as any. \r\n\r\n3. The value should NOT be treated as `falsy` EVER! Implicit coercion leads to many many bugs.\r\n\r\n4. The signature of the callback must follow this pattern: `(e: Event, v: value, ...rest: any[]) => void`\r\n\r\n5. If access to the event is granted, there really shouldn't be any reason to provide a `reason` argument to indicate what triggered the change. The event can be checked against it's type or it's properties. I think this could be more accurate. (debatable :grin: )\r\n\r\n@oliviertassinari @newoga @mbrookes Tell me what you guys think :grin: \r\n\r\n### The Roadmap:\r\n\r\n#### 1. Standardize The Following Components:\r\n\r\n- [x] `DatePicker: onChange(event, date)`\r\n- [ ] `DropDownMenu onChange(event, key, payload) => onChange(event, value, index)`, index?\r\n- [x] `IconMenu (event, value)`\r\n- [ ] `Drawer (deprecated prop) onChange(event, key, payload) => onChange(event, state)`\r\n- [x] `RadioButtonGroup onChange(event, newSelection)`\r\n- [ ] `SelectField, DropDownMenu onChange(event, index, value) => onChange(event, value, index)`\r\n- [x] `Slider onChange(event, value)`\r\n- [ ] `Tabs onChange(value) => onChange(event, value)`\r\n- [x] `TextField onChange(event) => onChange(event, value)` https://github.com/callemall/material-ui/pull/3699\r\n- [ ] `TimePicker onChange(null, time) => onChange(event, time)`\r\n- [ ] `Table` (https://github.com/callemall/material-ui/pull/3002)\r\n\r\n#### 2. Purge State:\r\n\r\n- [x] Create a stateful `StateWrapper` components that can be used to make components stateful, useful for forms. It must implement: `getValue()`, `setValue(value)`, `clearValue()`, `defaultValue prop`, `onChange prop: (event, value, ...rest) => void`\r\n- [ ] Clear state from all components that can be stateless. As much as possible.\r\n\r\n### 3. Documentation and deployment:\r\n\r\n- [ ] Figure out a way to make usage less pain full, something like: \r\n\r\n```js\r\nimport SelectField from 'material-ui/lib/SelectField'; // For the actual component\r\n// As opposed to:\r\nimport SelectField from 'material-ui/lib/SelectField/stateful'; // For the stateful version component\r\n```\r\n\r\nThis is easy to implement, but I don't know if we want this, we should discuss this too."},"comment":{"url":"https://api.github.com/repos/callemall/material-ui/issues/comments/226824041","html_url":"https://github.com/callemall/material-ui/issues/2957#issuecomment-226824041","issue_url":"https://api.github.com/repos/callemall/material-ui/issues/2957","id":226824041,"user":{"login":"alitaheri","id":8528759,"avatar_url":"https://avatars.githubusercontent.com/u/8528759?v=3","gravatar_id":"","url":"https://api.github.com/users/alitaheri","html_url":"https://github.com/alitaheri","followers_url":"https://api.github.com/users/alitaheri/followers","following_url":"https://api.github.com/users/alitaheri/following{/other_user}","gists_url":"https://api.github.com/users/alitaheri/gists{/gist_id}","starred_url":"https://api.github.com/users/alitaheri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alitaheri/subscriptions","organizations_url":"https://api.github.com/users/alitaheri/orgs","repos_url":"https://api.github.com/users/alitaheri/repos","events_url":"https://api.github.com/users/alitaheri/events{/privacy}","received_events_url":"https://api.github.com/users/alitaheri/received_events","type":"User","site_admin":false},"created_at":"2016-06-17T16:59:57Z","updated_at":"2016-06-17T16:59:57Z","body":"@rosskevin I personally prefer having a type system of any kind. But the issue is, not everyone know them. That means besides learning about our huge codebase, new contributors will also know about flow. That's not very good for big community-driven projects like this I'm afraid."}}
{"actor":{"display_login":"alitaheri"}}