Skip to content

Instantly share code, notes, and snippets.

Avatar

Martino Bordin martinobordin

View GitHub Profile
@martinobordin
martinobordin / class_decorator.ts
Created May 8, 2018 — forked from remojansen/class_decorator.ts
TypeScript Decorators Examples
View class_decorator.ts
function logClass(target: any) {
// save a reference to the original constructor
var original = target;
// a utility function to generate instances of a class
function construct(constructor, args) {
var c : any = function () {
return constructor.apply(this, args);
}
@martinobordin
martinobordin / AngularRxJs5DateHttpInterceptor.ts
Last active Jul 1, 2020
An Angular interceptor to parse string dates (ISO8601 format) from server response to JS Date Object. There are both RxJs 5 and RxJs 6 versions
View AngularRxJs5DateHttpInterceptor.ts
import { Injectable } from '@angular/core';
import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor, HttpErrorResponse, HttpResponse } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/do';
@Injectable()
export class AngularDateHttpInterceptor implements HttpInterceptor {
// Migrated from AngularJS https://raw.githubusercontent.com/Ins87/angular-date-interceptor/master/src/angular-date-interceptor.js
iso8601 = /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(([+-]\d\d:\d\d)|Z)?$/;
You can’t perform that action at this time.