###phd###
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Filters an array of objects with multiple criteria. | |
| * | |
| * @param {Array} array: the array to filter | |
| * @param {Object} filters: an object with the filter criteria as the property names | |
| * @return {Array} | |
| */ | |
| function multiFilter(array, filters) { | |
| const filterKeys = Object.keys(filters); | |
| // filters all elements passing the criteria |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import {createStore} from 'redux'; | |
| const counter = (state = 0, action) => { | |
| const index = { | |
| 'INCREMENT': () => { | |
| return state+1; | |
| }, | |
| 'DECREMENT': () => { | |
| return state-1; | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { takeLatest } from 'redux-saga' | |
| import { call, put } from 'redux-saga/effects' | |
| import fetch from 'isomorphic-fetch' | |
| import * as actions from './modules/grid' | |
| import * as api from '../lib/api' | |
| export function* fetchGrids(action) { | |
| try { | |
| const grids = yield call(api.GET, 'grids') | |
| yield put(actions.fetchGridsSuccess(grids)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript | |
| Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import snakeCase from 'lodash/snakeCase' | |
| /** | |
| * Convert a object with action creators created with | |
| * redux-actions createAction to a object with these | |
| * functions names as action types | |
| * | |
| * "someAction" becomes "SOME_ACTION" | |
| * | |
| * @param {Object} actions Object with action creators |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Create valid redux reducer with action types as object keys and values as | |
| * functions, instead of using Switch Statement | |
| * | |
| * Use it like this: | |
| * | |
| * `createReducer({ | |
| * // optional if you set a initial state as the second argument | |
| * initialState: {}, | |
| * |