getStyles<T extends keyof CSSStyleDeclaration>(styles: readonly T[]) {
return styles.reduce((res, style) => {
res[style] = this.$nativeElement.style[style];
return res;
}, {} as Pick<CSSStyleDeclaration, T>);
}
CSSStyleDeclaration
. GENERATE_SOURCEMAP=false
<WorkItem onClick={() => {alert(1)}} />
class WorkItem extends React.Component {
render() {
return <div onClick = {this.props.onClick}>i am clickable work item</div>
}
}
function timeout(ms, promise) {
return new Promise(function(resolve, reject) {
setTimeout(function() {
reject(new Error("timeout"))
}, ms)
promise.then(resolve, reject)
})
}
timeout(1000, fetch('/hello')).then(function(response) {
// process response
}).catch(function(error) {
// might be a timeout error
})