Skip to content

Instantly share code, notes, and snippets.

@jvinhit
jvinhit / cloudSettings
Last active August 10, 2020 02:32
Blackjack v.3
{"lastUpload":"2020-08-10T02:32:13.491Z","extensionVersion":"v3.4.3"}
@jvinhit
jvinhit / get_set_clone.js
Created March 3, 2021 03:32
get/ set nested object property via key (nested or no) funciton implement get/set of lodash
/* Implementation of lodash.get function */
function getProp( object, keys, defaultVal ){
keys = Array.isArray( keys )? keys : keys.split('.');
object = object[keys[0]];
if( object && keys.length>1 ){
return getProp( object, keys.slice(1) );
}
return object === undefined? defaultVal : object;
}
platformBrowserDynamic()
  .bootstrapModule(LoyaltyModule)
  .then(module => enableDebugTools(module.injector.get(ApplicationRef).components[0]))
  .catch(err => console.error(err));

then we run below command in chrome dev tools:

ng.profiler.timeChangeDetection()

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
import {FormGroup, ValidationErrors} from '@angular/forms';
export interface IFormError {
control: string;
error: string;
value: any;
}
export function getFormValidationErrors(form: FormGroup) {
const result = [];