Skip to content

Instantly share code, notes, and snippets.

View iamdustan's full-sized avatar

Dustan Kasten iamdustan

View GitHub Profile
import WS from 'ws';
function setupDevtools() {
var messageListeners = [];
var closeListeners = [];
var ws = new WS('ws://localhost:8097/devtools');
// this is accessed by the eval'd backend code
var FOR_BACKEND = { // eslint-disable-line no-unused-vars
wall: {
listen(fn) {
/* @flow */
type Auth = {
username: string;
password: string;
}
type Auth2 = {
username: string;
}
declare module 'redux-form' {
declare type Errors = Object;
declare type ValidationPromise = Promise<?Errors>;
declare type MapPropsToValues = (props:Object) => Object;
declare type ReduxFormProps = {
active: string;
asyncValidate: Function;
asyncValidating: boolean;
// action-creator.js
type Auth = {
/**
* email address used as login
*/
login: string;
/**
* password
*/
/** @flow */
import type {Action} from '../redux';
type Errors = Object;
type ValidationPromise = Promise<?Errors>;
type MapPropsToValues = (props:Object) => Object;
type ReduxFormProps = {
import {QL, dispatch} from 'redux-ql';
import {connect} from 'react-redux'
// before
connect(state => ({
user: {
name: state.user.name,
id: state.user.id
},
// our apis return successfully from an HTTP/fetch promise standpoint for
// response payloads with error codes. We would like the reducer to receive this
// an rejection and not have to manage unwrapping that itself.
export default () => next => action =>
action.type === 'FETCH'
? next(action).then(res => res.hasOwnProperty('error') ? Promise.reject(res) : res)
: next(action);
/** @flow */
import React, {Component, PropTypes} from 'react';
import Popout from 'react-popout';
import {
DevTools,
DebugPanel,
LogMonitor
} from 'redux-devtools/lib/react';
@iamdustan
iamdustan / babel-plugin-react-docgen.js
Last active September 23, 2015 19:55
Get reactjs/react-docgen information in your babel plugin.
/* eslint-disable */
import * as docgen from 'react-docgen';
import {readFileSync as read} from 'fs';
export default function ({Plugin, parse, types: t}) {
return new Plugin('styleguide-plugin', {
visitor: {
Program: {
enter (node, parent, scope, file) {
// console.log('Program file', file.opts.filename);
/* @flow */
// override Flow's setTimeout declaration for node
declare function setTimeout(callback: any, ms: number, ...args: Array<any>): {ref: Function; unref: Function};
var timeout = setTimeout(function() {}, 100);
timeout.unref();