-
Notifications
You must be signed in to change notification settings - Fork 11
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
Conversation
Codecov Report
@@ Coverage Diff @@
## main #936 +/- ##
=======================================
Coverage 85.14% 85.14%
=======================================
Files 806 806
Lines 16643 16644 +1
Branches 2097 2098 +1
=======================================
+ Hits 14170 14171 +1
Misses 2441 2441
Partials 32 32
Continue to review full report at Codecov.
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@@ -52,9 +52,13 @@ export class SpinnerComponent implements OnChanges { | |||
|
|||
public state$?: Observable<SpinnerAsyncState>; | |||
|
|||
public ngOnInit(): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onInit shouldn't be necessary on top of the onChanges. In fact, these days I find onInit is rarely what we want, it just distract from real workhorse, onChanges. I'd consider it maybe not a red flag, but a yellow one.
Specifically in this case as long as data$ is assigned, line 61 would have already run before we got here. This would only be useful in the case where data$ is never assigned (which isn't really a use case, but if you want to default state$ to NEVER on line 53, that's fine, avoids making it optional too).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't assign anything to data then like 61 wouldn't execute. Bare minimum, i will have to assign undefined
.
In my use case, I am not assigning anything to data$. So Spinner will always be in loading
state and on the parent side we will just keep updating the loading message like 'Received 10 events' -> Received 20 events
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could just assign NEVER and it would work for your special case, right? why build it into the component?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could. But doesn't it read better? Also, shouldn't the spinner support undefined/missing data$ case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could go either way, doesn't feel particularly better to me. That said, if you prefer that my initial suggestion was to default it to NEVER anyway - just via assignment rather than onInit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, let me confirm it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep or just public state$: Observable<SpinnerAsyncState> = of(SpinnerAsyncState.Loading);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Don't you have more code reviews in another 7 hours?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more like 5
Description
Please include a summary of the change, motivation and context.
fix: setting default never for data$
This will allow us to set dynamic loading message
Testing
Please describe the tests that you ran to verify your changes. Please summarize what did you test and what needs to be tested e.g. deployed and tested helm chart locally.
Checklist:
Documentation
Make sure that you have documented corresponding changes in this repository or hypertrace docs repo if required.