{"action":"opened","issue":{"url":"https://api.github.com/repos/goatslacker/alt/issues/412","labels_url":"https://api.github.com/repos/goatslacker/alt/issues/412/labels{/name}","comments_url":"https://api.github.com/repos/goatslacker/alt/issues/412/comments","events_url":"https://api.github.com/repos/goatslacker/alt/issues/412/events","html_url":"https://github.com/goatslacker/alt/issues/412","id":96742782,"number":412,"title":"Configuring actions through parameters.","user":{"login":"kevin-wolf","id":3157426,"avatar_url":"https://avatars.githubusercontent.com/u/3157426?v=3","gravatar_id":"","url":"https://api.github.com/users/kevin-wolf","html_url":"https://github.com/kevin-wolf","followers_url":"https://api.github.com/users/kevin-wolf/followers","following_url":"https://api.github.com/users/kevin-wolf/following{/other_user}","gists_url":"https://api.github.com/users/kevin-wolf/gists{/gist_id}","starred_url":"https://api.github.com/users/kevin-wolf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevin-wolf/subscriptions","organizations_url":"https://api.github.com/users/kevin-wolf/orgs","repos_url":"https://api.github.com/users/kevin-wolf/repos","events_url":"https://api.github.com/users/kevin-wolf/events{/privacy}","received_events_url":"https://api.github.com/users/kevin-wolf/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-23T06:27:35Z","updated_at":"2015-07-23T06:27:35Z","closed_at":null,"body":"Hello guys, I am wondering if I am doing this correctly, or there is another way to achieve it:\r\n\r\nI am creating a chat component on top of React and Alt for internal use on some projects on the company I work.\r\n\r\nWhat I want to achieve, is to make my component modular so I can set the socket url like this:\r\n```html\r\n<Chat socket=\"https://apogeelive-chat-server.herokuapp.com/\" />\r\n```\r\n\r\nI did achieved the above by adding a setter function on the `ChatActions.js` file, but I am not sure if this can be the best practice:\r\n```js\r\nimport alt from '../alt';\r\nimport io from 'socket.io-client';\r\n\r\nlet socket;\r\n\r\n@alt.createActions\r\nclass ChatActions {\r\n\r\n  constructor () {\r\n    this.generateActions('uidReceived', 'messageReceived');\r\n  }\r\n\r\n  setSocketUrl (url) {\r\n    socket = io.connect(url);\r\n\r\n    socket.on('chat:receivedMessage', (message) => {\r\n      ChatActions.messageReceived(message);\r\n    });\r\n\r\n    socket.on('chat:receiveUid', (id) => {\r\n      ChatActions.uidReceived(id);\r\n    });\r\n  }\r\n\r\n  addMessage (message) {\r\n    socket.emit('chat:addMessage', message);\r\n  }\r\n\r\n}\r\n\r\nexport default ChatActions;\r\n```\r\n\r\nAnd configuring it within my component:\r\n\r\n```javascript\r\n// Third parties.\r\nimport React from 'react';\r\nimport connectToStores from 'alt/utils/connectToStores';\r\n\r\n// Actions & Stores.\r\nimport ChatActions from '../actions/ChatActions';\r\nimport ChatStore from '../stores/ChatStore';\r\n\r\n// UI Components.\r\nimport ChatItem from './ChatItem';\r\nimport ChatForm from './ChatForm';\r\n\r\n\r\n@connectToStores\r\nclass ChatView extends React.Component {\r\n\r\n  static getStores () {\r\n    return [ ChatStore ];\r\n  }\r\n\r\n  static getPropsFromStores () {\r\n    return ChatStore.getState();\r\n  }\r\n\r\n  constructor (props) {\r\n    super(props);\r\n    this.addMessage = this.addMessage.bind(this);\r\n    ChatActions.setSocketUrl(this.props.socket);\r\n  }\r\n\r\n  addMessage (text) {\r\n    ChatActions.addMessage({ uid : this.props.uid, text : text });\r\n  }\r\n\r\n  render () {\r\n    let messages = this.props.chatMessages.map((message) => {\r\n      return <ChatItem key={message.id} message={message} uid={this.props.uid} />;\r\n    });\r\n\r\n    return <div>\r\n      <ul>{messages}</ul>\r\n      <hr />\r\n      <ChatForm onAddMessage={this.addMessage} />\r\n    </div>;\r\n  }\r\n\r\n}\r\n\r\nexport default ChatView;\r\n```\r\n\r\nMy question is:\r\n- **Is this the correct way to achieve what I want?**\r\n- **There is another way to achieve this, that I am missing?**\r\n\r\nRegards."}}