{"action":"opened","issue":{"url":"https://api.github.com/repos/goatslacker/alt/issues/16","labels_url":"https://api.github.com/repos/goatslacker/alt/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/goatslacker/alt/issues/16/comments","events_url":"https://api.github.com/repos/goatslacker/alt/issues/16/events","html_url":"https://github.com/goatslacker/alt/issues/16","id":58488482,"number":16,"title":" Uncaught TypeError: Illegal invocation when registering dispatch in a store","user":{"login":"bizmurr","id":10281776,"avatar_url":"https://avatars.githubusercontent.com/u/10281776?v=3","gravatar_id":"","url":"https://api.github.com/users/bizmurr","html_url":"https://github.com/bizmurr","followers_url":"https://api.github.com/users/bizmurr/followers","following_url":"https://api.github.com/users/bizmurr/following{/other_user}","gists_url":"https://api.github.com/users/bizmurr/gists{/gist_id}","starred_url":"https://api.github.com/users/bizmurr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bizmurr/subscriptions","organizations_url":"https://api.github.com/users/bizmurr/orgs","repos_url":"https://api.github.com/users/bizmurr/repos","events_url":"https://api.github.com/users/bizmurr/events{/privacy}","received_events_url":"https://api.github.com/users/bizmurr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-02-22T03:27:45Z","updated_at":"2015-02-22T03:27:45Z","closed_at":null,"body":"So I'm trying to follow your example of:\r\n\r\n```javascript\r\nalt.createStore(class MyStore {\r\n  constructor() {\r\n    this.dispatcher.register(console.log)\r\n  }\r\n})\r\n```\r\n\r\nMy alt looks like this:\r\n\r\n```\r\nimport Alt from 'alt';\r\n\r\nvar altFlux = new Alt();\r\n\r\nexport default altFlux;\r\n```\r\n\r\nMy store looks like this:\r\n\r\n```\r\nimport altFlux from '../altFlux';\r\nimport AlertMessageActions from '../actions/AlertMessageActions';\r\nimport UserDataActions from '../actions/UserDataActions';\r\n\r\nclass AlertMessageStore {\r\n  constructor() {\r\n    this.dispatcher.register(console.log);\r\n\r\n    this.bindActions(AlertMessageActions);\r\n    this.bindAction(UserDataActions.receiveUserDataError, this.onReceiveAlertError);\r\n\r\n    this.message = null;\r\n    this.alertLevel = null;\r\n    this.error = null;\r\n    this.alertVisible = false;\r\n    this.dismissAfter = null;\r\n  }\r\n\r\n  onReceiveAlertSuccess(msg) {\r\n    this._initGenericAlert('success', msg);\r\n  }\r\n\r\n  onReceiveAlertError(msg) {\r\n    console.log('GOT AN ERR!');\r\n    this._initErrorAlert(msg);\r\n  }\r\n\r\n  _initGenericAlert(lvl, msg) {\r\n    this.alertLevel = lvl;\r\n    this.message = msg;\r\n    this.error = false;\r\n    this.alertVisible = true;\r\n    this.dismissAfter = 15000;\r\n  }\r\n\r\n  _initErrorAlert(msg) {\r\n    this.alertLevel = 'danger';\r\n    this.message = msg;\r\n    this.error = true;\r\n    this.alertVisible = true;\r\n    this.dismissAfter = null;\r\n  }\r\n}\r\n\r\nexport default altFlux.createStore(AlertMessageStore);\r\n```\r\n\r\nMy action:\r\n\r\n```\r\nimport altFlux from '../altFlux';\r\nimport UserDataAPI from '../utils/api/UserDataAPI';\r\nimport ErrorToJSON from '../utils/serializers/ErrorToJSON';\r\n\r\nclass UserDataActions {\r\n  constructor() {\r\n    this.generateActions(\r\n      'receiveUserData',\r\n      'receiveUserDataError'\r\n    );\r\n  }\r\n\r\n  getUserData(params = { useCache: true }) {\r\n    this.dispatch();\r\n\r\n    let localData = UserDataAPI.getLocalUserData();\r\n\r\n    if (localData && params.useCache) {\r\n      this.actions.receiveUserData(localData);\r\n    } else {\r\n      UserDataAPI.getUserData().then((res) => {\r\n        this.actions.receiveUserData(res.body.data);\r\n      }).catch((err) => {\r\n        let error = ErrorToJSON.superagent(err);\r\n\r\n        this.actions.receiveUserDataError(error);\r\n      });\r\n    }\r\n  }\r\n}\r\n\r\nexport default altFlux.createActions(UserDataActions);\r\n```\r\n\r\nMy view:\r\n\r\n```\r\nimport React from 'react';\r\nimport { Jumbotron, Button, ButtonToolbar, ModalTrigger } from 'react-bootstrap';\r\nimport NewUserHelpModal from './NewUserHelpModal';\r\nimport UserDataActions from '../../actions/UserDataActions';\r\n\r\nvar NewUserMessage = React.createClass({\r\n  componentWillReceiveProps(nextProps) {\r\n  },\r\n\r\n  componentDidUpdate(prevProps, prevState) {\r\n    console.log('not ready!');\r\n  },\r\n\r\n  _fetchUserData() {\r\n    UserDataActions.getUserData({ useCache: false });\r\n  },\r\n\r\n  render() {\r\n    return (\r\n      <Button bsStyle='success' onClick={this._fetchUserData}>Fetch User Data</Button>\r\n   )\r\n}\r\n```\r\n\r\nHowever, when I click the button to trigger the action, in my console log I get:\r\n\r\n```\r\nUncaught TypeError: Illegal invocation\r\n```\r\n\r\n```\r\n  Dispatcher.prototype.$Dispatcher_invokeCallback=function(id) {\r\n    this.$Dispatcher_isPending[id] = true;\r\n    this.$Dispatcher_callbacks[id](this.$Dispatcher_pendingPayload);\r\n    this.$Dispatcher_isHandled[id] = true;\r\n  };\r\n```\r\n\r\nMy intention is when the user clicks the button, it calls the `UserDataActions.getUserData` and then if it fails, the error is sent to the `AlertMessageStore`.\r\n\r\nRemoving the line `this.dispatcher.register(console.log)`, and everything works OK. Any ideas? Am I missing something?\r\n"}}