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
| of(1, 2, 3).pipe(toArray()).subscribe(console.log); |
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
| withLatestFrom(this.control.valueChanges.pipe(startWith(null))); |
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
| @Component({ | |
| selector: 'my-component', | |
| template: '<div><input [formControl]="control"/></div>', | |
| }) | |
| export class MyComponent implements OnInit { | |
| control = new FormControl(''); | |
| ngOnInit() { | |
| fromEvent(document.body, 'click').pipe( | |
| withLatestFrom(this.control.valueChanges), |
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 ActionNames { | |
| private static names = new Set<string>(); | |
| static create(name: string): string { | |
| if (ActionNames.names.has(name)) { | |
| throw new Error('An Action with this type already exists!'); | |
| } | |
| ActionNames.names.add(name); | |
| return name; | |
| } |
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
| const loadData = createAction('[Home Page] Load Data'); | |
| const loadDataSuccess = createAction( | |
| '[Home Page] Load Data', | |
| props<{payload: object}>(), | |
| ); | |
| const _dataReducer = createReducer( | |
| {}, | |
| on(loadDataSuccess, (state, {payload}) => ({...state, ...payload})), | |
| ); |
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 BaseComponent { | |
| @Input() something = ''; | |
| } | |
| @Component({ | |
| selector: 'my-selector', | |
| template: 'Empty', | |
| inputs: ['something'], | |
| }) | |
| export class InheritedComponent extends BaseComponent { |
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 BaseComponent { | |
| @Input() something = ''; | |
| } | |
| @Component({ | |
| selector: 'my-selector', | |
| template: 'Empty', | |
| }) | |
| export class InheritedComponent extends BaseComponent { | |
| // actual class implementation |
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
| this.control.disable({emitEvent: false}); |
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
| @Component({ | |
| selector: 'my-component', | |
| template: ` | |
| <input [formControl]="control"> | |
| <button (click)="toggleEnabledState()">Toggle State</button> | |
| `, | |
| }) | |
| export class MyComponent implements OnInit { | |
| control = new FormControl('Default 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
| (value: string) => this.ngControl.control.setValue(value.trim(), {emitEvent: false}), |