Skip to content

Instantly share code, notes, and snippets.

View neurosnap's full-sized avatar

Eric Bower neurosnap

View GitHub Profile
@neurosnap
neurosnap / actionCreator.js
Created November 19, 2016 03:39
Simple action creator
// actionCreator.js
export default (type: string) => (payload: Object) => ({ type, payload });
// Examples
export const FETCH_THREADS = 'threadFetch/FETCH';
export const fetchThreads = actionCreator(FETCH_THREADS);
export const FETCH_NEXT_PAGE = 'threadFetch/FETCH_NEXT_PAGE';
export const fetchNextPage = actionCreator(FETCH_NEXT_PAGE);
describe('getFolderCount', () => {
const getFolderCount = selectors.getFolderCount;
before(() => {
sinon.stub(selectors, 'getDisplayFolderProp');
sinon.stub(selectors, 'getFoldersHash');
sinon.stub(selectors, 'calcFolderCount');
sinon.stub(coreSelectors, 'getMailboxes');
sinon.stub(coreSelectors, 'getThreadIdsByFolder');
getFolderCount({}, {});
});
@neurosnap
neurosnap / plugin.js
Created February 6, 2017 15:18
example plugin middleware
/* REDUCER MIDDLEWARE */
export const PluginMiddleware = (actionTypes) => store => next => action => {
action.actionTypes = actionTypes;
return next(action);
}
// example reducer
const counter = (state, action) => {
const actionTypes = action.actionTypes;
const handler = {
get(target, name) {
return name;
},
};
const actionTypeCreator = new Proxy({}, handler);
const { ADD_SOMETHING, REMOVE_SOMETHING } = actionTypeCreator;

Keybase proof

I hereby claim:

  • I am neurosnap on github.
  • I am neurosnap (https://keybase.io/neurosnap) on keybase.
  • I have a public key ASD15DIHe4ANJndK6jBxMLOtAD35MP78OGTKphHnJqByIQo

To claim this, I am signing this object:

import * as React from 'react';
import axios from 'axios';
import { connect } from 'react-redux';
import { getFormSubmitErrors } from 'redux-form';
+ import { push } from 'react-router-redux';
import { globals, GridContainer } from '@shared/atoms';
import styled from '@shared/ui';
import { buildFormData } from '@shared/lib/formatters';
@neurosnap
neurosnap / monad.js
Last active September 21, 2018 21:04
const RESULT = "RESULT";
const isResult = obj => obj && obj.type === RESULT;
const Result = value => ({
type: RESULT,
value
});
const NOTHING = "NOTHING";
const isNothing = obj => obj && obj.type === NOTHING;
const Nothing = value => ({
@neurosnap
neurosnap / robodux.ts
Last active February 6, 2020 04:21
new robodux api experiment
import createTable from './slice-map';
import createIndexMany from './create-index';
import createPrimitive from './slice-assign';
import createLoaderTable from './slice-loading-map';
const createIndex = (p: any) => createTable<{ [key: string]: string }>(p);
interface User {
id: string;
email: string;
@neurosnap
neurosnap / phaser.ts
Created March 1, 2020 02:42
phaser collision
import Phaser from 'phaser';
class MainScene extends Phaser.Scene {
_player: Phaser.GameObjects.Sprite | null;
_cursors: Phaser.Types.Input.Keyboard.CursorKeys | null;
_layer: Phaser.Tilemaps.StaticTilemapLayer | null;
constructor() {
super({
key: 'MainScene',
@neurosnap
neurosnap / emitter.ts
Last active September 27, 2022 13:53
const ee = emitter();
ee.on(function* clicker() {
while (true) {
const event = yield take('click');
console.log('click event!', event);
}
});
ee.on(function* once() {
const event = yield take('click');
console.log('on listen for event once!', event);