Skip to content

Instantly share code, notes, and snippets.

Last active October 28, 2015 10:23
What would you like to do?
Reflux + Axios.
'use strict';
var Reflux = require('reflux');
var axios = require('axios');
var Actions = Reflux.createActions({
load: {
children: ['completed', 'failed']
Actions.load.listen(function() {
var that = this;
axios.get('/whatever').then(function(res) {
module.exports = Actions;
'use strict';
var Reflux = require('reflux');
var actions = require('./actions');
module.exports = Reflux.createStore({
init: function() { = [];
this.listenTo(actions.load.completed, this.loadCompleted);
this.listenTo(actions.load.failed, this.loadFailed);
loadCompleted: function(data) { = data;
loadFailed: function(err) {
Copy link

God dammit, I got it now...

I have to trigger actions.load() to actually trigger the ajax call... I thought the first one was automatically triggered... my fault...

Thanks for the example :)

Copy link

Wow this helped, but please how do you use this inside the react component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment