Skip to content

Instantly share code, notes, and snippets.

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import componentQueries from 'react-component-queries';
import { connect } from 'react-redux';
import { connectProcesses } from 'redux-saga-process';
import _ from 'lodash';
@bradennapier
bradennapier / documentation-plugin.js
Created September 15, 2017 01:44
Start of Webpack Plugin
// @flow
import ModuleFilenameHelpers from 'webpack/lib/ModuleFilenameHelpers';
import type {
FormatConfig,
PluginConfigurationType,
UserPluginConfigurationType,
} from './types';
import path from 'path';
/* @flow */
import PromiseQueue from 'promise-queue-observable';
import { config as AWSConfig, CognitoIdentityCredentials, CognitoSyncManager } from 'aws-sdk';
import 'amazon-cognito-js';
import {
CognitoUserPool,
CognitoUser,
AuthenticationDetails,
const REACT_PROTOTYPE = [
'constructor',
'autobind',
'childContextTypes',
'componentDidMount',
'componentDidUpdate',
'componentWillMount',
'componentDidCatch',
'componentWillReceiveProps',
'componentWillUnmount',
@bradennapier
bradennapier / React Timeout Map
Last active October 1, 2017 23:16
Example to show implementation of hoist methods
import * as React from 'react';
import hoistMethods from 'hoist-non-react-methods';
const METHODS = {
set(timeoutID, fn, delay) {
METHODS.delete.call(this, timeoutID);
const cancelToken = setTimeout(() => {
METHODS.delete.call(this, timeoutID);
fn();
}, delay);
04623daa9b2fb27cb36375183ada46e4cdcebaf83bc1071608ac494a473439e4a55bda3dbe11f46868129dd87653c0f379117e31989efbdb8c2796ad245d3a6c53
/*
A Process allows us to define a modular "Logic Component" which may
interact with our app in a variety of ways based on it's design.
Processes are given properties when configured which will define if/how
they reduce the redux state, what actions they make available to our
components, when our process should load and with what scope,
what types we want to listen for, and more.
This allows us to build truly encapsulated and re-useable application
import { Process } from 'redux-saga-process';
import { call, put } from 'redux-saga/effects';
import { createSelector } from 'reselect';
import { createTaskManager } from 'saga-task-manager';
import startUserPositionObserver from 'saga-geolocation-observer';
import handleUserPosition from './sagas/handleUserPosition';
import * as React from 'react';
/*
Called to build our states schema.
*/
const $ = StateManager({
/* `config` to configure globally - passed to all state modules */
config: {},
async function Event(req, res, data, callback) {
if (data.query.block) {
const prefix = data.query.block.split('_')[0];
// If the parameter passed in starts with xrb_ or nano_, send them to an account search
if (prefix === 'xrb' || prefix === 'nano') {
res.writeHead(302, { Location: `/${data.params.lang}/explore/account/${data.query.block}` });
} else {
res.writeHead(302, { Location: `/${data.params.lang}/explore/block/${data.query.block}` });
}
return res.end();