View selector with deep equal
This file contains 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 { isEqual } from 'lodash'; | |
import { | |
createFeatureSelector, | |
createSelector, | |
createSelectorFactory, | |
defaultMemoize, | |
} from '@ngrx/store'; | |
import * as fromFlightBooking from './flight-booking.reducer'; | |
export const selectFlightBookingState = createFeatureSelector< |
View init.spec.ts
This file contains 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 { test, expect } from '@playwright/test'; | |
test.describe('initial test', () => { | |
test('holidays', async ({ page }) => { | |
await page.goto('https://genuine-narwhal-f0f8ad.netlify.app/'); | |
await page.click('[data-testid=btn-holidays]'); | |
await expect(page.locator('mat-drawer-content')).toContainText( | |
'Choose among our Holidays' | |
); |
View scheduler.spec.ts
This file contains 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'; | |
import { fakeAsync, flush, TestBed } from '@angular/core/testing'; | |
import { | |
SchedulerEvent, | |
SchedulerModule, | |
} from '@progress/kendo-angular-scheduler'; | |
const baseData: any[] = [ | |
{ | |
TaskID: 4, |
View customer.component.ts
This file contains 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 CustomerComponent { | |
formGroup = new FormGroup({}); | |
@Input() customer: Customer | undefined; | |
@Output() save = new EventEmitter<Customer>(); | |
@Output() remove = new EventEmitter<Customer>(); | |
fields: FormlyFieldConfig[] = [ | |
// form configuration | |
]; |
View customer.actions.ts
This file contains 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 removed = createAction( | |
'[CUSTOMER] Removed', | |
props<{ customers: Customer[] }>() | |
); | |
// further actions (removed here for simplicity reasons) | |
export const CustomerActions = { | |
get, |
View index.ts
This file contains 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 * from './lib/customer-data.module'; | |
export { PublicCustomerActions as CustomerActions } from './lib/customer.actions'; | |
export * from './lib/customer.selectors'; |
View edit-customer.component.ts
This file contains 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: 'eternal-edit-customer', | |
template: ` <eternal-customer | |
*ngIf="customer$ | async as customer" | |
[customer]="customer" | |
(save)="this.submit($event)" | |
(remove)="this.remove($event)" | |
></eternal-customer>`, | |
}) | |
export class EditCustomerComponent implements OnInit { |
View data.guard.ts
This file contains 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
@Injectable({ | |
providedIn: 'root', | |
}) | |
export class DataGuard implements CanActivate { | |
constructor(private store: Store<CustomerAppState>) {} | |
canActivate(): Observable<boolean> { | |
this.store.dispatch(CustomerActions.get()); | |
return this.store | |
.select(fromCustomer.isLoaded) |
View reducer.ts
This file contains 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 interface State { | |
customers: Customer[]; | |
} | |
const initialState = { | |
customers: [] | |
} |
View reducer.ts
This file contains 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 interface State { | |
loadStatus: 'NOT_LOADED' | 'LOADING' | 'LOADED'; | |
customers: Customer[]; | |
} | |
const initialState = { | |
loadStatus: 'NOT_LOADED', | |
customers: [] | |
} |
NewerOlder