Skip to content

Instantly share code, notes, and snippets.

🏡
Remote Fullstack Node.js / Frontend React.js

Vítězslav Ackermann Ferko ackvf

🏡
Remote Fullstack Node.js / Frontend React.js
Block or report user

Report or block ackvf

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ackvf
ackvf / eventloop.js
Last active Nov 14, 2019
Understanding the Event Loop
View eventloop.js
function callback(arg) {
setTimeout(console.log, 0, arg, ' # 4 timeout ');
setImmediate(console.log, arg, ' # 5 immediate');
process.nextTick(console.log, arg, ' # 2 nextTick ');
(async () => { await undefined; console.log(arg, ' # 3 await '); })();
console.log(arg, '# 1 sync ');
}
setTimeout(callback, 0, ' # 4 timeout ');
setImmediate(callback, ' # 5 immediate');
@ackvf
ackvf / direct-call.js
Last active Aug 12, 2019
promise-and-await
View direct-call.js
'use strict';
const wait = (ms, data) => log(ms, data) || new Promise(resolve => setTimeout(resolve, ms, data))
const reject = (ms, data) => log(ms, data) || new Promise((r, reject) => setTimeout(reject, ms, data))
const e = e => (console.log('Error:', e), 'err-' + e)
const l = l => (console.log('Done:', l), l)
const log = (ms, data) => console.log('Started', data, ms)
async function async1() {
@ackvf
ackvf / higherOrderComponent.tsx
Last active Oct 18, 2019
TypeScript sessions
View higherOrderComponent.tsx
import React from 'react';
import PropTypes from 'prop-types';
import { IMetricsServiceClient } from '@containers/App/model';
export interface IWithMetricsServiceClient {
metricsServiceClient: IMetricsServiceClient;
}
@ackvf
ackvf / index.tsx
Last active Aug 22, 2019
React TypeScript types
View index.tsx
/* Type guards */
export function is<T>(obj: any, assertion: (obj: T) => boolean): obj is T {
return assertion(obj);
}
function isFish(pet: Fish | Bird): pet is Fish {
return (<Fish>pet).swim !== undefined;
}
@ackvf
ackvf / functionArgumentsType.ts
Created Mar 12, 2019
Extracting Arguments type of an abstract action executor method
View functionArgumentsType.ts
// Class-based Tree Shaking - HTTP203 @ Google Chrome Developers
// https://www.youtube.com/watch?v=lsd2-TCgHEs&t=599
class Store {
/**
* Do the given action with the given parameters.
*
* @param {A => R} action Action to be taken.
* @param {A} args Arguments to be passed to the action.
* @returns {R} Returns the result of original action call.
You can’t perform that action at this time.