Skip to content

Commit 5de8ca7

Browse files
authored
fix: setting default never for data$ (#936)
* fix: setting default never for data$ * refactor: addressing review comments * refactor: fixing lint issues
1 parent fa25c51 commit 5de8ca7

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

projects/components/src/spinner/spinner.component.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('Spinner component', () => {
3535
}
3636
});
3737

38-
expectObservable(spectator.component.state$!).toBe('(y)', { y: 'loading' });
38+
expectObservable(spectator.component.state$).toBe('(y)', { y: 'loading' });
3939
});
4040
}));
4141

@@ -52,7 +52,7 @@ describe('Spinner component', () => {
5252
}
5353
);
5454

55-
expectObservable(spectator.component.state$!).toBe('(x-y|)', { x: 'loading', y: 'success' });
55+
expectObservable(spectator.component.state$).toBe('(x-y|)', { x: 'loading', y: 'success' });
5656
});
5757
}));
5858

@@ -69,7 +69,7 @@ describe('Spinner component', () => {
6969
}
7070
);
7171

72-
expectObservable(spectator.component.state$!).toBe('(x-y|)', { x: 'loading', y: 'error' });
72+
expectObservable(spectator.component.state$).toBe('(x-y|)', { x: 'loading', y: 'error' });
7373
});
7474
}));
7575
});

projects/components/src/spinner/spinner.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ChangeDetectionStrategy, Component, Input, OnChanges } from '@angular/core';
22
import { IconType } from '@hypertrace/assets-library';
33
import { TypedSimpleChanges } from '@hypertrace/common';
4-
import { Observable, of } from 'rxjs';
4+
import { NEVER, Observable, of } from 'rxjs';
55
import { catchError, endWith, ignoreElements, startWith } from 'rxjs/operators';
66
import { IconSize } from '../icon/icon-size';
77

@@ -50,11 +50,11 @@ export class SpinnerComponent implements OnChanges {
5050
@Input()
5151
public theme: SpinnerTheme = SpinnerTheme.Light;
5252

53-
public state$?: Observable<SpinnerAsyncState>;
53+
public state$: Observable<SpinnerAsyncState> = of(SpinnerAsyncState.Loading);
5454

5555
public ngOnChanges(changes: TypedSimpleChanges<this>): void {
56-
if (changes.data$ && this.data$) {
57-
this.state$ = this.mapObservableState(this.data$);
56+
if (changes.data$) {
57+
this.state$ = this.mapObservableState(this.data$ ?? NEVER);
5858
}
5959
}
6060

0 commit comments

Comments
 (0)