Skip to content

Instantly share code, notes, and snippets.

View SaurabhLpRocks's full-sized avatar

Saurabh Palatkar SaurabhLpRocks

View GitHub Profile
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/map';
import { Injectable } from '@angular/core';
import { Headers, Http, Request, RequestOptions, Response, XHRBackend } from '@angular/http';
import { Router } from '@angular/router';
import { Observable } from 'rxjs/Observable';
export class AppModule {
/**
* Allows for retrieving singletons using `AppModule.injector.get(MyService)`
* This is good to prevent injecting the service as constructor parameter.
*/static injector: Injector;
constructor(public appState: AppState, injector: Injector) {
AppModule.injector = injector;
}
}
import { Injectable } from '@angular/core';
import { RequestOptions, Response } from '@angular/http';
import { Observable } from 'rxjs/Rx';
import { HttpService } from '../../theme/services/http.service';
import { Error } from '../interfaces/error.interface';
import { ServerResponse } from '../interfaces/server-response.interface';
import { appVariables } from './../../app.constants';
import { CustomErrorHandlerService } from './custom-error-handler.service';
export interface ServerResponse {
data: any;
error: string[];
message: string;
}
import { Injectable } from '@angular/core';
import { Response, ResponseOptions } from '@angular/http';
import { Error } from '../interfaces';
import { TostNotificationService } from './toast-notification.service';
@Injectable()
export class CustomErrorHandlerService {
import { Injectable } from '@angular/core';
import { Response } from '@angular/http';
import { Observable } from 'rxjs/Rx';
import { appApiResources } from '../../app.constants';
import { LoginResponse } from '../../theme/interfaces/login-response.interface';
import { HelperService } from '../../theme/services';
import { BaseService } from '../../theme/services/base.service';
@Injectable()
@SaurabhLpRocks
SaurabhLpRocks / detach-change-detector.ts
Created May 10, 2018 09:06
Angular Performance tips
import {AfterViewInit, ChangeDetectorRef} from '@angular/core';
@Component(…)
class AppComponent implements AfterViewInit {
constructor(private cdr: ChangeDetectorRef) {}
ngAfterViewInit() {
// We only want to detach the change detectors after change detection has been
// performed for the first time
this.cdr.detach();
}
import {AfterViewInit, ChangeDetectorRef} from '@angular/core';
@Component(…)
class AppComponent implements AfterViewInit {
constructor(private cdr: ChangeDetectorRef) {}
ngAfterViewInit() {
// We only want to detach the change detectors after change detection has been
// performed for the first time
this.cdr.detach();
}
import {enableProdMode} from '@angular/core';
if (ENV === 'production') {
enableProdMode();
}
var compression = require('compression')
var express = require('express')
var app = express()
app.use(compression())