This shows the execution order given JavaScript's Call Stack, Event Loop, and any asynchronous APIs provided in the JS execution environment (in this example; Web APIs in a Browser environment)
Given the code
"Variables {{{ | |
let mapleader="," | |
" }}} | |
" Globals {{{ | |
syntax enable | |
set fileencoding=utf-8 | |
set listchars=space:· " show whitespaces as dots |
function retry(fn) { | |
return function(data) { | |
return new Promise((resolve, reject) => { | |
var retries = 10, | |
error; | |
function attempt() { | |
if (retries === 0) { | |
reject(error); | |
} |
import React from 'react'; | |
export default function(LoadingComponent, WrappedComponent) { | |
return function(props) { | |
return ( | |
{ | |
(props.status === 'LOADING') ? <LoadingComponent /> : <WrappedComponent {...props.data} /> | |
} | |
) | |
}; |
import React from 'react'; | |
export default function(mapPropsToData, WrappedComponent) { | |
return function(props) { | |
function onClick(event) { | |
if (event.target.tagName === 'A') { | |
const data = mapPropsToData ? mapPropsToData(props) : {}; | |
// Process data | |
} |