Created
March 12, 2015 00:24
-
-
Save janmarek/6a6008077d4420fe4b16 to your computer and use it in GitHub Desktop.
React DI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dic.factory('components/Komponenta', [ | |
'issueActions', 'issueStore', 'components/Spinner', 'components/Errors', 'components/Input', | |
require('./components/Komponenta') | |
]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var React = require('react'); | |
var StoreWatch = require('../mixins/StoreWatch'); | |
/** | |
* Komponenta factory | |
* | |
* @param {IssueActions} issueActions | |
* @param {IssueStore} issueStore | |
* @param {Spinner} Spinner | |
* @param {Errors} Errors | |
* @param {Input} Input | |
* @return {Komponenta} | |
*/ | |
module.exports = function (issueActions, issueStore, Spinner, Errors, Input) { | |
var Komponenta = React.createClass({ | |
mixins: [StoreWatch(issueStore)], | |
getFluxState() { | |
return { | |
neco: issueStore.getNeco() | |
} | |
}, | |
submit() { | |
issueActions.saveNeco(); | |
}, | |
render() { | |
if (!neco.isLoaded()) { | |
return <Spinner/>; | |
} | |
return <form onSubmit={this.submit}> | |
<Input /> | |
<Button /> | |
</form>; | |
} | |
}); | |
return Komponenta; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment