This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { HttpClient, HttpErrorResponse } from '@angular/common/http'; | |
import { Injectable } from '@angular/core'; | |
import { BehaviorSubject, Subject, throwError } from 'rxjs'; | |
import { catchError, finalize } from 'rxjs/operators'; | |
import { StoreSettings } from './models/store-settings.model'; | |
@Injectable({ providedIn: 'root' }) | |
export abstract class StoreService<T> { | |
//#region Subjects, Objservables, Getter/Setters | |
private itemsSubject = new BehaviorSubject<T[]>([]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
load(filter = '', order = '', page = 0, pageSize = 0, useCache = false, append = false) { | |
if (useCache && this.items?.length > 0) { | |
return; | |
} | |
this.loading = true; | |
const url = this.settings.url + `?filter=${filter}&order=${order}&page=${page}&pageSize=${pageSize}`; | |
this.http | |
.get<T[]>(url) | |
.pipe( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { HttpClient } from '@angular/common/http'; | |
import { Injectable } from '@angular/core'; | |
import { BehaviorSubject} from 'rxjs'; | |
import { StoreSettings } from './models/store-settings.model'; | |
@Injectable({ providedIn: 'root' }) | |
export abstract class StoreService<T> { | |
protected itemsSubject = new BehaviorSubject<T[]>([]); | |
items$ = this.itemsSubject.asObservable(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger: | |
- master | |
pool: | |
vmImage: 'ubuntu-latest' | |
steps: | |
- task: NodeTool@0 | |
inputs: | |
versionSpec: '10.x' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Router } from '@angular/router'; | |
import { Observable } from 'rxjs'; | |
import { AuthService } from '../auth.service'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class HasRoleGuard implements CanActivate { | |
constructor( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
longSentence = JSON.parse('{"value": "Lorem ipsum dolor sit ' + | |
'amet, consectetur adipiscing elit, sed do ' + | |
'eiusmod tempor incididunt ut labore et dolore ' + | |
'magna aliqua. Ut enim ad minim veniam, quis nostrud ' + | |
'exercitation ullamco laboris nisi ut aliquip ex ea ' + | |
'commodo consequat. Duis aute irure dolor in ' + | |
'reprehenderit in voluptate velit esse cillum dolore ' + | |
'eu fugiat nulla pariatur. Excepteur sint occaecat ' + | |
'cupidatat non proident, sunt in culpa qui officia ' + | |
'deserunt mollit anim id est laborum."}'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
longSentence = JSON.parse(`{"value": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."}`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
longSentence = JSON.parse(`{"value": "Lorem ipsum dolor sit \ | |
amet, consectetur adipiscing elit, sed do \ | |
eiusmod tempor incididunt ut labore et dolore \ | |
magna aliqua. Ut enim ad minim veniam, quis nostrud \ | |
exercitation ullamco laboris nisi ut aliquip ex ea \ | |
commodo consequat. Duis aute irure dolor in \ | |
reprehenderit in voluptate velit esse cillum dolore \ | |
eu fugiat nulla pariatur. Excepteur sint occaecat \ | |
cupidatat non proident, sunt in culpa qui officia \ | |
deserunt mollit anim id est laborum."}`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { BehaviorSubject } from 'rxjs'; | |
import { User } from '../models/user.model'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class AuthService { | |
private _user$: BehaviorSubject<User> = new BehaviorSubject<User>(null); | |
user$ = this._user$.asObservable(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Angular CRUD Service": { | |
"prefix": "crud-service", | |
"body": [ | |
"import { Injectable } from '@angular/core';", | |
"import { HttpClient } from '@angular/common/http';", | |
"import { Observable, throwError } from 'rxjs';", | |
"import { ${1:className} } from '@cook/models/${2:classFileName}.interface';", | |
"import { environment } from '@cook/environment/environment';", | |
"import { catchError } from 'rxjs/operators';", |