-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fix(reduce/scan): both scan/reduce operators now accepts undefined
itself as a valid seed
#2050
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d34e49b
fix(scan): scan operator now accepts `undefined` itself as a valid se…
jayphelps 34e2e4f
fix(reduce): reduce operator now accepts `undefined` itself as a vali…
jayphelps 0827628
Merge branch 'master' into scan-seed
jayphelps 0df3dc9
Merge branch 'master' into scan-seed
jayphelps File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 can totally see why you're passing
hasSeed
to the Subscriber via the constructor. It makes it less polymorphic. However, I do feel like the subscriber itself should be able to determine if it has a seed. How does that effect performance?Do you even think it matters? I'm on the fence. It probably doesn't. It just feels weird as an API, albeit an internal one to be like
seed
,hasSeed
on the tail end of a call.Thoughts?
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.
we would have to have additional branching, would we not?
And then each class downstream would have to duplicate the
arguments.length >= 2
check wouldn't they?I did it this way because it seemed to me the best performant and the other solutions had a lot of duplication. It's very non-obvious at first, but best I can tell you have to atleast check at the original call site otherwise you'll lose that info because of the
Operator#call
architecture. The additional choices are whether or not you repeat the samearguments.length >= 2
check in the Operator and Subscriber constructors and branch each time, or you just decide once and pass down a totally awkwardhasSeed
from the top. I chose the later, since it's a private API but yeah, it's awkward.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.
👍
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.
@jayphelps I suppose applying the ScanOperator constructor vis-a-vis
new ScanOperator(...arguments)
would allow theScanOperator
to determine whether the seed exists, and the only benefit I see there would be for people who manually import theScanOperator
to use withlift
instead of thescan
function, which I imagine is < 0.0001% of consumers.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.
@trxcllnt sorry, I'm not 100% sure what your suggestion is? Is it to move the
arguments.length >= 2
check into theScanOperator
constructor and usenew ScanOperator(...arguments)
?A little pedantic of me, but that will perform not as well because
new ScanOperator(...arguments)
transpiles to something likeBut this really isn't the typical hot code path, so prolly doesn't matter. I'm open to that, if you all have stronger opinions than me. It's definitely the prettiest solution of them all!
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.
@jayphelps no you're totally right and I should have clarified I was playing devil's advocate. I'm 100% against doing that.