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 { | |
| AfterViewInit, | |
| Component, | |
| ElementRef, | |
| EventEmitter, | |
| Input, | |
| OnDestroy, | |
| OnInit, | |
| Output, | |
| ViewChild |
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 { | |
| width: 24px; | |
| height: 128px; | |
| display: inline-block; | |
| cursor: pointer; | |
| } | |
| text { | |
| font-size: 8px; | |
| text-transform: uppercase; | |
| font-weight: bold; |
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
| <svg viewBox="0 0 24 128" #slider> | |
| <text y="-4" | |
| fill="lightgrey" class="slider-text" | |
| *ngIf="!!label" | |
| transform="rotate(90)">{{ label }}</text> | |
| <path d="M 12 0 v 128" fill="none" stroke="grey"></path> | |
| <circle r="4" cx="12" [attr.cy]="cursorPt.y" fill="currentColor"></circle> | |
| </svg> |
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
| case actions.LOAD_SUMMARY_SUCCESS: | |
| return userAdapter.addMany(action.users, state); | |
| case actions.LOAD_DETAIL: | |
| return { ...state, selectedUserId: action.id }; | |
| case actions.LOAD_DETAIL_SUCCESS: | |
| if (!!state.entities[action.user.id]) { | |
| return userAdapter.updateOne({ | |
| id: action.user.id, |
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 const userAdapter = createEntityAdapter<Partial<User>>(); | |
| export interface State extends EntityState<Partial<User>> { | |
| selectedUserId: number; | |
| } | |
| const initialState: State = userAdapter.getInitialState({ | |
| selectedUserId: 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
| export class LoadSummaryAction implements Action { | |
| readonly type = LOAD_SUMMARY; | |
| } | |
| export class LoadSummarySuccessAction implements Action { | |
| readonly type = LOAD_SUMMARY_SUCCESS; | |
| constructor(public users: Partial<User>[]) {} | |
| } | |
| export class LoadDetailAction implements Action { | |
| readonly type = LOAD_DETAIL; |
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
| <div class="columns is-multiline is-mobile" | |
| *ngIf="!(isLoading$ | async); else loading"> | |
| <div class="column is-one-third" *ngFor="let user of users$ | async"> | |
| <app-contact-card [user]="user"></app-contact-card> | |
| </div> | |
| </div> | |
| <ng-template #loading>Loading users...</ng-template> |
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 ContactListComponent implements OnInit { | |
| /* Container component */ | |
| isLoading$: Observable<boolean>; | |
| users$: Observable<User[]>; | |
| constructor(private store: Store<fromStore.State>) { | |
| this.isLoading$ = store.select(fromStore.getUsersLoading); | |
| this.users$ = store.select(fromStore.getUsers); |
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
| StoreModule.forRoot(reducers), | |
| !environment.production ? StoreDevtoolsModule.instrument() : [], | |
| EffectsModule.forRoot([ | |
| UsersEffect, | |
| UserDetailsEffect | |
| ]) |
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 UsersEffect { | |
| constructor( | |
| private actions$: Actions, | |
| private userService: UserService | |
| ) {} | |
| @Effect() | |
| loadUsers$: Observable<Action> = this.actions$ | |
| .ofType(userActions.LOAD) |