Skip to content

Instantly share code, notes, and snippets.

for (let i = 0; i < array.length; i++) {
const el = array[i];
// do something here
}
const setStatus = (status, message) => SET_STATUS({ status, message });
const getResponseJson = async response => response.json();
const fetchUrl = url => () => fetch(url);
function updateState(dispatch) {
const dispatchStatus = status => () => dispatch(setStatus(status));
const dispatchError = ({ message }) => dispatch(setStatus('error', message));
const dispatchState = data => dispatch(SET_STATE({ data }));
return Promise.resolve()
const setStatus = (status, message) => SET_STATUS({ status, message });
const getResponseJson = async response => response.json();
const fetchUrl = url => () => fetch(url);
function updateState(dispatch) {
const dispatchStatus = status => () => dispatch(setStatus(status));
const dispatchError = ({ message }) => dispatch(setStatus('error', message));
const dispatchState = data => dispatch(SET_STATE({ data }));
dispatchStatus('submitting')();
const getResponseJson = async response => response.json();
function updateState(dispatch) {
const dispatchStatus = status => dispatch(SET_STATUS({ status }));
const dispatchError = e =>
dispatch(SET_STATUS({ status: 'error', message: e.message }));
const dispatchState = data => dispatch(SET_STATE({ data }));
dispatchStatus('submitting');
const getResponseJson = async response => response.json();
function updateState(dispatch) {
const dispatchStatus = status => dispatch(SET_STATUS({ status }));
const dispatchError = e =>
dispatch(SET_STATUS({ status: 'error', message: e.message }));
const dispatchState = data => dispatch(SET_STATE({ data }));
dispatchStatus('submitting');
function updateState(dispatch) {
const dispatchStatus = status => dispatch(SET_STATUS({ status }));
const dispatchError = e =>
dispatch(SET_STATUS({ status: 'error', message: e.message }));
dispatchStatus('submitting');
return fetch('https://example.com/api/a')
.then(() => {
dispatchStatus('processing');
function updateState(dispatch) {
// helper functions
const dispatchError = e =>
dispatch(SET_STATUS({ status: 'error', message: e.message }));
dispatch(SET_STATUS({ status: 'submitting' }));
return fetch('https://example.com/api/a')
.then(() => {
dispatch(SET_STATUS({ status: 'processing' }));
function updateState(dispatch) {
dispatch(SET_STATUS({ status: 'submitting' }));
return fetch('https://example.com/api/a')
.then(() => {
dispatch(SET_STATUS({ status: 'processing' }));
return fetch('https://example.com/api/b')
.then(response => {
return response
.json()
describe('The Initialization Form', () => {
beforeEach(() => {
cy.fixture('config.json').as('config')
indexedDB.deleteDatabase('localforage')
cy.server()
cy.route({
method: 'POST',
@baranovxyz
baranovxyz / Map.vue
Last active October 30, 2021 13:46
Example of using datamaps with vuejs
<template>
<div class="map" :style="`height: ${height}px;`">
<svg ref="svg" class="map-container"
xmlns="http://www.w3.org/2000/svg"
:width="width" :height="height"
shape-rendering="geometricPrecision"
:viewBox="`500 100 200 400`"
>
</svg>
</div>