Skip to content

Instantly share code, notes, and snippets.

View keithstric's full-sized avatar

Keith Strickland keithstric

  • Douglasville, GA
  • 13:45 (UTC -04:00)
View GitHub Profile
@Injectable({
providedIn: 'root'
})
export class ErrorService {
public errorEvent: Subject<Error> = new Subject<any>();
constructor(
private _ui: UiService
) { }
@keithstric
keithstric / http-request-interceptor.ts
Created June 9, 2020 13:57
Loading spinner http interceptor
import { Injectable } from '@angular/core';
import {
HttpRequest,
HttpHandler,
HttpEvent,
HttpInterceptor, HttpResponse
} from '@angular/common/http';
import { Observable } from 'rxjs';
import {catchError, map} from 'rxjs/operators'
import {LoadingService} from '../../layout/services/loading/loading.service';
@keithstric
keithstric / app.component.html
Last active October 21, 2020 13:28
Loading spinner app.component
<!-- Loading spinner -->
<div *ngIf="loading" class="loading-container flex-content-center">
<mat-progress-spinner
color="primary"
mode="indeterminate">
</mat-progress-spinner>
</div>
<!-- the application -->
<div class="site-container">
@keithstric
keithstric / loading.service.ts
Last active June 9, 2020 13:49
Loading spinner loading service
import { Injectable } from '@angular/core';
import {BehaviorSubject} from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class LoadingService {
loadingSub: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
/**
* Contains in-progress loading requests
@keithstric
keithstric / index.test.js
Created February 17, 2020 16:04
Adventures in Unit Testing 3
const someFunction = require('./index');
const rewire = require('rewire');
let app;
beforeEach(() => {
someFunction();
app = rewire('./index.js');
});
test('it should increment evtCount', () => {
@keithstric
keithstric / index.test.js
Last active February 17, 2020 16:05
Adventures in Unit Testing 2
const someFunction = require('./index');
const rewire = require('rewire');
let app;
beforeEach(() => {
someFunction();
app = rewire('./index.js');
});
test('it should increment evtCount', () => {
@keithstric
keithstric / index.js
Last active February 17, 2020 15:22
Adventures in Unit Testing 1
const EventEmitter = require('events').EventEmitter;
global.customEmitter = new EventEmitter();
let evtCount = 0;
module.exports = function someFunction() {
global.customEmitter.addListener('foo', somePrivateFunction);
}
function somePrivateFunction() {
evtCount++;
import * as ts from 'typescript';
let options = {
stripInternal: true,
target: ts.ScriptTarget.ES5,
experimentalDecorators: true,
listEmittedFiles: true
};
function transform(ctx: ts.TransformationContext): ts.Transformer<ts.SourceFile> {