Skip to content

Instantly share code, notes, and snippets.

@ellismarkf
ellismarkf / polling-saga.js
Last active April 2, 2020 07:02
Polling with redux-saga
import { call, put, race, fork, take } from 'redux-saga/effects'
function delay(duration) {
const promise = new Promise(resolve => {
setTimeout(() => resolve(true), duration)
});
return promise;
}
// Fetch data every 20 seconds
@ellismarkf
ellismarkf / README.md
Last active August 15, 2016 15:47
javascript array utility that flattens an arbitrarily nested array of arrays of integers

flatten

Just a small function that does as the description explains: flattens an arbitrarily nested array of arrays of integers. Uses a recursive strategy to handle nesting, and written in a functional style.

This implementation assumes that arrays only contain integers, not any other primitives. The logic that decides whether to recursively call the function again is predicated on the presence of a length property, which Integers in Javascript do not have. Passing an array containing other primitives to the flatten function will result in a runtime error.

usage