Skip to content

Instantly share code, notes, and snippets.

04623daa9b2fb27cb36375183ada46e4cdcebaf83bc1071608ac494a473439e4a55bda3dbe11f46868129dd87653c0f379117e31989efbdb8c2796ad245d3a6c53
@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);
const REACT_PROTOTYPE = [
'constructor',
'autobind',
'childContextTypes',
'componentDidMount',
'componentDidUpdate',
'componentWillMount',
'componentDidCatch',
'componentWillReceiveProps',
'componentWillUnmount',
/* @flow */
import PromiseQueue from 'promise-queue-observable';
import { config as AWSConfig, CognitoIdentityCredentials, CognitoSyncManager } from 'aws-sdk';
import 'amazon-cognito-js';
import {
CognitoUserPool,
CognitoUser,
AuthenticationDetails,
@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';
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 / redux-saga-process-example.js
Created June 25, 2017 05:51
A complete example of all the options available in redux-saga-process-v2
/*
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
@bradennapier
bradennapier / ReduxSagaProcess.js
Last active June 19, 2017 23:06
A Complete Runthrough of ReduxSagaProcess's Properties and Features.
/*
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
@bradennapier
bradennapier / process-shell.js
Created June 19, 2017 11:26
Process Shell example for Widgets
import { Process } from 'redux-saga-process';
import { call, put, select } from 'redux-saga/effects';
import { createSelector } from 'reselect';
import _ from 'lodash';
/**
* GET_DEFAULT_WIDGET_STATE
*/
const GET_DEFAULT_WIDGET_STATE = () => ({
rehydrated: false,
@bradennapier
bradennapier / process-example.js
Last active June 19, 2017 06:34
Process Example posts
import { Process } from 'redux-saga-process';
import { put, call } from 'redux-saga/effects';
const build_config = config => ({
reduces: 'posts',
pid: 'posts',
exports: ['actions', 'selectors'],
log: false,
...config,
});