Skip to content

Instantly share code, notes, and snippets.

@SandeepThomas
SandeepThomas / socket.service.ts
Created November 15, 2018 11:04
Angular RxJs Websocket
import { Injectable } from '@angular/core';
import { fromEvent, NextObserver, Observable, Subject, Subscription, timer } from 'rxjs';
import { _throw } from 'rxjs/observable/throw';
import { finalize, mergeMap, retryWhen, take } from 'rxjs/operators';
import { WebSocketSubject } from 'rxjs/webSocket';
import { environment } from '../../../environments/environment';
import { AuthService } from './authentication.service';
@Injectable()
export class SocketService {
@SandeepThomas
SandeepThomas / translate.loader.ts
Last active November 14, 2018 10:47
ngx translate custom loader
/*
* Custom Translate Loader to reload lang JSON on network failure
*/
import { TranslateLoader } from "@ngx-translate/core";
import { Injectable } from "@angular/core";
import { HttpHeaders, HttpClient } from "@angular/common/http";
import { ConnectionService } from ".";
import { Observable } from "rxjs";
import { filter, take } from "rxjs/operators";
import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AuthGuard, SocketInitialize } from './shared/services/authguard.service';
const APP_ROUTES: Routes = [
{ path: '', loadChildren: './landing/landing.module#LandingModule' },
{ path: 'home', loadChildren: './home/home.module#HomeModule', canActivate: [AuthGuard, SocketInitialize] },
{ path: '**', redirectTo: '' }
];
@SandeepThomas
SandeepThomas / datepickerLocaldateDirective.js
Last active March 8, 2021 00:23 — forked from weberste/gist:354a3f0a9ea58e0ea0de
Dates only with Angular-UI Bootstrap datepicker - In Epoch time / Unix time
app.directive('datepickerLocaldate', ['$parse', function ($parse) {
var directive = {
restrict: 'A',
require: ['ngModel'],
link: link
};
return directive;
function link(scope, element, attr, ctrls) {
var ngModelController = ctrls[0];