Skip to content

Instantly share code, notes, and snippets.

@ZackDeRose
ZackDeRose / snippet.column-with-sorting.table.component.html
Created July 18, 2018 04:04
Column Sorting for "Angular CDK Tables" article
<!-- Hero Name Column -->
<ng-container cdkColumnDef="name">
<th cdk-header-cell *cdkHeaderCellDef (click)="adjustSort('name')">
Hero Name
<span *ngIf="sortKey$.value === 'name'">
{{ sortDirection$.value === 'asc' ? '↥' : '↧' }}
</span>
</th>
<td cdk-cell *cdkCellDef="let row"> {{row.name}} </td>
</ng-container>
@ZackDeRose
ZackDeRose / snippet.adjust-sort.table.component.ts
Created July 18, 2018 04:07
AdjustSort() for "Angular CDK Table" article
adjustSort(key: string) {
if (this.sortKey$.value === key) {
if (this.sortDirection$.value === 'asc') {
this.sortDirection$.next('desc');
} else {
this.sortDirection$.next('asc');
}
return;
}
@ZackDeRose
ZackDeRose / foo.ts
Created January 13, 2019 23:50
foo.ts
export class Foo {
private static _count = 0;
id: number;
constructor() {
this.id = ++Foo._count; // starts with 1
}
}
describe('Foo Class', () => {
describe('constructor', () => {
const fooClassRef = Foo as any; // to pass typechecking
beforeEach(() => {
console.log(`start of beforeEach: ${fooClassRef._count}`);
fooClassRef._count = 0;
console.log(`end of beforeEach: ${fooClassRef._count}`);
});
@ZackDeRose
ZackDeRose / car-list-facade.ts
Last active January 16, 2019 04:16
car-list-facade.ts
@Injectable()
export class CarsListFacade extends CarsFacade {
_source = 'Cars List';
constructor(private store$: Store<any>) {
super(store$);
}
}
@ZackDeRose
ZackDeRose / cars.facade.ts
Last active January 16, 2019 04:16
cars.facade.ts
export abstract class CarsFacade {
protected _source: string;
loaded$ = this.store.select(carsQuery.getLoaded);
allCars$ = this.store.select(carsQuery.getAllCars);
selectedCars$ = this.store.select(carsQuery.getSelectedCars);
constructor(private store: Store<CarsState>) {}
protected loadAll() {

Workspace Schematics

A utilitarian guide for creating Nx Workspace Schematics

Notes on Schematic - When They Are and Are Not Useful

Schematics are a one-time event that adjusts your filesystem - usually for the purpose of automating boilerplate or configuration.

If you've ever written down a list of things to do or files to adjust everytime you create a component (for example), a schematic is an excellent solution.

const COUNT = 10000;
interface Hero {
heroName: string;
heroId: number;
}
interface AlterEgo {
realName: string;
heroId: number;
@ZackDeRose
ZackDeRose / README.md
Last active February 25, 2021 17:46 — forked from kentcdodds/README.md
Function syntaxes supported by TypeScript

TypeScript Function Syntaxes

I'm trying to create examples of all the different ways to write functions and function type definitions in TypeScript.

One requirement is these examples must work with strict mode (noImplicitAny, etc) enabled.

If I'm missing anything, please add comments below with examples. I'll eventually put this into a blog post.

Keep in mind that there are TONS of combinations of different syntaxes. I only want to include those which are less obvious combinations or unique in some way.

Rough Schedule

breaks are in bold

  • 8:00am PST | 11:00am EST - Introductions
  • 8:05am PST | 11:05am EST - Lab 1
  • 8:30am PST | 11:30am EST - Lab 2
  • 9:00am PST | 12:00pm EST - Lab 3
  • 9:30am PST | 12:30pm EST - BREAK!!
  • 10:00am PST | 1:00pm EST - Lab 4