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 { NgModule } from '@angular/core' | |
| import { ToastComponent } from './toast.component'; | |
| @NgModule({ | |
| declarations: [ToastComponent], | |
| entryComponents: [ToastComponent] | |
| }) | |
| export class ToastModule { } |
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 { Component } from '@angular/core'; | |
| @Component({ | |
| selector: 'app-toast', | |
| template: ` | |
| <div>This is a toast message</div> | |
| ` | |
| }) | |
| export class ToastComponent { } |
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
| loadDocuments$ = this.actions$.pipe( | |
| ofType<documentActions.Fetch>(documentActions.FETCH) | |
| switchMap((action) => | |
| this.documentsService | |
| .getDocuments().pipe( | |
| map(docs => new documentActions.FetchSuccess(docs)), | |
| catchError(error => of( | |
| new ErrorOccurred({ | |
| action, | |
| error, |
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
| export function reducer(state = initialState, action: AuthActionsUnion): State { | |
| switch (action.type) { | |
| case AuthActionTypes.LoginSuccess: { | |
| return { | |
| ...state, | |
| loggedIn: true, | |
| user: action.payload.user, | |
| }; | |
| } |
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
| export class ErrorOccurred implements Action { | |
| readonly type = ERROR_OCCURRED; | |
| constructor( | |
| readonly payload: { | |
| action?: Action; | |
| error?: ErrorData; | |
| }, | |
| ) {} | |
| } |
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
| export class DocumentContainer { | |
| companyName$ = this.store.select(detailsSelector.getDocumentCompanyName); | |
| documentStatus$ = this.store.select(detailsSelector.getDocumentStatus); | |
| constructor(private store: Store<AppStore.AppState>) { } | |
| } |
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
| export class DocumentContainer { | |
| companyName$: Observable<string>; | |
| documentStatus$: Observable<number>; | |
| constructor( | |
| private store: Store<AppStore.AppState>, | |
| ) { | |
| this.companyName$ = this.store.select(detailsSelector.getDocumentCompanyName); | |
| this.documentStatus$ = this.store.select(detailsSelector.getDocumentStatus); |
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 { Action } from '@ngrx/store'; | |
| export const LOG_ERROR = '[Logger] Log Error'; | |
| export const LOG_WARNING = '[Logger] Log Warning'; | |
| export const LOG_INFO = '[Logger] Log Info'; | |
| export class LogError implements Action { | |
| readonly type = LOG_ERROR; | |
| constructor(readonly payload: { message: string }) { } | |
| } |
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
| class Point { | |
| constructor(public point: number) {} | |
| } | |
| function creator<T, G>(type: { new (args: G): T }) { | |
| return (args: G) => new type(args); | |
| } | |
| [1, 2, 3].map(creator(Point)); |
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 { Directive, HostListener, ElementRef } from '@angular/core'; | |
| import { Router } from '@angular/router'; | |
| import { isNil } from 'ramda'; | |
| @Directive({ | |
| selector: 'a[appExternalUrl]', | |
| }) | |
| export class ExternalUrlDirective { | |
| constructor(private el: ElementRef, private router: Router) {} |