Skip to content

fix: setting default never for data$ #936

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions projects/components/src/spinner/spinner.component.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('Spinner component', () => {
}
});

expectObservable(spectator.component.state$!).toBe('(y)', { y: 'loading' });
expectObservable(spectator.component.state$).toBe('(y)', { y: 'loading' });
});
}));

Expand All @@ -52,7 +52,7 @@ describe('Spinner component', () => {
}
);

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

Expand All @@ -69,7 +69,7 @@ describe('Spinner component', () => {
}
);

expectObservable(spectator.component.state$!).toBe('(x-y|)', { x: 'loading', y: 'error' });
expectObservable(spectator.component.state$).toBe('(x-y|)', { x: 'loading', y: 'error' });
});
}));
});
8 changes: 4 additions & 4 deletions projects/components/src/spinner/spinner.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ChangeDetectionStrategy, Component, Input, OnChanges } from '@angular/core';
import { IconType } from '@hypertrace/assets-library';
import { TypedSimpleChanges } from '@hypertrace/common';
import { Observable, of } from 'rxjs';
import { NEVER, Observable, of } from 'rxjs';
import { catchError, endWith, ignoreElements, startWith } from 'rxjs/operators';
import { IconSize } from '../icon/icon-size';

Expand Down Expand Up @@ -50,11 +50,11 @@ export class SpinnerComponent implements OnChanges {
@Input()
public theme: SpinnerTheme = SpinnerTheme.Light;

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

public ngOnChanges(changes: TypedSimpleChanges<this>): void {
if (changes.data$ && this.data$) {
this.state$ = this.mapObservableState(this.data$);
if (changes.data$) {
this.state$ = this.mapObservableState(this.data$ ?? NEVER);
}
}

Expand Down