Skip to content

Instantly share code, notes, and snippets.

View ThomasBurleson's full-sized avatar

Thomas Burleson ThomasBurleson

View GitHub Profile
export interface ResponseError = [any, Error];	// Tuple to return either 

 * special promise trap to build tuple of reponse and error
const trap = (promise): Promise<ResponseError> => {  
  return promise
 .then(data =&gt; ([data, undefined]))
ThomasBurleson /
Last active February 23, 2020 16:04
Git - Benefits of Flat Commit History

Flawed Commit Strategy

Developers often want to condense their git log output. However without a proper git commit strategy (and conventions), those condensed outputs are still flawed.

For details on condensed git log outputs, see Improve your Git Log Output

Consider a git lg output for a typical project:


ThomasBurleson /
Last active October 11, 2020 17:52
Why is RxJS::defer() important!

Quite simply, because Observables can encapsulate many different types of sources and those sources don't necessarily have to obey that interface. Some like Promises always attempt to eagerly compete.


const promise = $.get('');
<!-- wInViewRoot directive is needed to specify the `root` for `IntersectionObserver` and some other it's options e.g. `margin` -->
<div class="container" wInViewRoot="viewport">
Any content can be here
<!-- Content will be replaced by a placeholder <div> with the same height as original content.
Also `InViewItemComponent`s change detector will be detached when it become invisible which means
all the content's change detectors won't be reachable and will be inactive as well. -->
...or any other content can be here
ThomasBurleson / books-page.component.ts
Last active December 28, 2019 17:03
Compressing View Logic with Facades
* Snippet from blog article:
selector: 'abl-books-page',
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
ThomasBurleson / log.operator.ts
Last active January 11, 2019 14:04
Using custom RxJS log() operator
export function log(task: string) {
const announceCompleted = () => {
console.log(`${task} %ccomplete`, 'color: green');
return function<T>(source: Observable<T>) {
return source.pipe(
import {
} from '@angular/core';
ThomasBurleson / cars.facade.spec.ts
Last active April 21, 2023 02:32
Testing NgRx Facades with async/await.
import { NgModule } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { readFirst } from '@nrwl/nx/testing';
import { EffectsModule } from '@ngrx/effects';
import { StoreModule, Store } from '@ngrx/store';
import { NxModule } from '@nrwl/nx';
ThomasBurleson /
Last active June 15, 2023 13:32
Custom Nx workspace schematic to build a custom 'state' library.


We want to build a custom schematic for company Aero that will internally do two things:

  • build a new ngrx library using Nx workspace naming conventions
  • generate ngrx state-management files; include the *.facade.* files

Important: This example is valid ONLY for Nx v6.2.x or higher!

ThomasBurleson /
Created May 27, 2018 14:52
Webstorm FileWatcher for Prettier formatting

prettier-filewatcher webstorm