Currently it for clent-side apps only. Not for universall (isomorphic) apps. Will add it soon
I'm using the promise middleware to dispatch actions like this:
| // getComponent is a function that returns a promise for a component | |
| // It will not be called until the first mount | |
| function asyncComponent(getComponent) { | |
| return class AsyncComponent extends React.Component { | |
| static Component = null; | |
| state = { Component: AsyncComponent.Component }; | |
| componentWillMount() { | |
| if (!this.state.Component) { | |
| getComponent().then(Component => { |
| export class Dispatcher { | |
| constructor () { | |
| this.events = {}; | |
| } | |
| addListener (event, callback) { | |
| // Check if the callback is not a function | |
| if (typeof callback !== 'function') { | |
| console.error(`The listener callback must be a function, the given type is ${typeof callback}`); | |
| return false; |
| // credit goes to this stack overflow post - http://stackoverflow.com/questions/20646836/is-there-any-way-to-import-a-json-filecontains-100-documents-in-elasticsearch | |
| var elasticsearch = require('elasticsearch'), | |
| fs = require('fs'), | |
| pubs = JSON.parse(fs.readFileSync(__dirname + '/pubs.json')), // name of my first file to parse | |
| forms = JSON.parse(fs.readFileSync(__dirname + '/forms.json')); // and the second set | |
| var client = new elasticsearch.Client({ // default is fine for me, change as you see fit | |
| host: 'localhost:9200', | |
| log: 'trace' | |
| }); |
Currently it for clent-side apps only. Not for universall (isomorphic) apps. Will add it soon
I'm using the promise middleware to dispatch actions like this:
| /* | |
| ##Device = Desktops | |
| ##Screen = 1281px to higher resolution desktops | |
| */ | |
| @media (min-width: 1281px) { | |
| /* CSS */ | |
| 'use strict'; | |
| /*****************NATIVE forEACH*********************/ | |
| Array.prototype.myEach = function(callback) { | |
| for (var i = 0; i < this.length; i++) | |
| callback(this[i], i, this); | |
| }; | |
| //tests |