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
| @Route('/feature1/', {lazy: true}) | |
| @DefaultRoute('/feature1/users') | |
| @NgModule({ | |
| declarations: [ | |
| UsersComponent | |
| ] | |
| }) | |
| export class Feature1Module{ | |
| } |
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
| expect('.someDiv').toHaveClass('some class') | |
| expect('.someDiv').toHaveText('some text') | |
| expect('.someDiv').toBeChecked() | |
| expect('.someDiv').toBeDisabled() |
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
| host.dispatchMouseEvent('.someDiv', 'click'); //somediv could be an existing element as well | |
| host.dispatchKeyboardEvent('.someDiv', 'keydown', 'p'); |
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 SomeOtherComponent extends Mixin1(Mixin2(Unsubscribable(ComponentRoot))){ | |
| //... | |
| } |
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 SomeNewComponent extends Unsubscribable(ComponentRoot){ | |
| constructor(someObservable: Observable){ | |
| super(); //must be called because we extend base | |
| someObservable | |
| .pipe(takeUntil(this.unsubscribeAll)) | |
| .subscribe(value => {//do something with value}); | |
| } | |
| } |
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 Unsubscribable<T extends Constructor<{}>>(Base: T) { | |
| class WithUnsubscribable extends Base implements OnDestroy { | |
| protected unsubscribeAll: Subject<any> = new Subject(); | |
| ngOnDestroy(): void { | |
| this.unsubscribeAll.next(); | |
| this.unsubscribeAll.complete(); | |
| } | |
| } |
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
| // default basic constructor required for mixins themselves | |
| export type Constructor<T> = new (...args: any[]) => T; | |
| // base class basically used as a placeholder | |
| export class ComponentRoot { | |
| } |
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 SomeComponent { | |
| property: string; | |
| ... | |
| someMethod(){ | |
| this.property = 'new value'; | |
| this.cdr.markForCheck(); | |
| } | |
| constructor(private cdr: ChangeDetectorRef){ } | |
| } |
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, Input } from '@angular/core'; | |
| import { coerceBooleanProperty } from '@angular/cdk/coercion'; | |
| @Component({ | |
| selector: 'some-component', | |
| template: `` | |
| }) | |
| export class SomeComponent { | |
| private _showLabel: boolean; //set a default val if necessary | |
| @Input() |
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
| using LinqToDb; | |
| namespace Demo { | |
| public class Repository { | |
| public UserWithProfile GetUserById(int id){ | |
| using (var db = GetDataContext(...)) | |
| { | |
| return db.Users.FirstOrDefault(x=>x.Id == id); | |
| } | |
| } |
NewerOlder