Skip to content

Instantly share code, notes, and snippets.

View l0gicgate's full-sized avatar
🏁
Sprinting

Pierre B. l0gicgate

🏁
Sprinting
View GitHub Profile
@l0gicgate
l0gicgate / component.js
Last active June 17, 2022 18:23
Redux + Websockets
import React, { PropTypes } from 'react';
import { connect } from 'react-redux';
import { initializeSocket } from './redux/socket.js';
class App extends React.Component {
static propTypes = {
dispatch: PropTypes.func.isRequired,
socket: PropTypes.object.isRequired,
};
@l0gicgate
l0gicgate / FetchActionCreators.js
Last active May 23, 2016 14:39
Reusable action creators / reducers.
import axios from 'axios';
class FetchActionCreators {
constructor(endpoint, actions) {
const [REQUEST, SUCCESS, FAILURE] = actions;
this.actions = {
REQUEST,
SUCCESS,
FAILURE,
export default class ReducerChain {
constructor(reducers) {
this.reducers = reducers;
if (!Array.isArray(reducers)) {
throw new Error('To create a reducer chain you must pass in an array of functions.');
}
return this.reducer;
}