-
Notifications
You must be signed in to change notification settings - Fork 944
Enable passing custom fetch function to BrowserHTTPRequest constructor #1422
Conversation
@nsthorat For context: this is the first of two PRs that will fix the issue in which tfjs-node users have to override |
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.
@caisq a general question about this. Why go the subclassing approach instead of allowing a user to pass a fetch function to the load function?
Reviewable status: 0 of 1 approvals obtained (waiting on @nsthorat)
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.
The two approaches (subclassing vs. adding a new arg to the constructor of BrowserHTTPRequest
should both help us achieve the same goal. But I feel the subclassing approach is a little cleaner because it avoids adding an additional arg toBrowserHTTPRequest
constructor.
WDYT?
Reviewable status: 0 of 1 approvals obtained (waiting on @nsthorat)
My 2c is that passing a function is more canonical JS than inheritance (and inheritance usually is more confusing anyways). I don't care that much though. |
Gentle ping @ reviewers. I may not have made it clear in the previous comment, but the inheritance pattern has been replaced with the additional arg. |
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 @caisq! LGTM
Reviewed 1 of 4 files at r1, 3 of 3 files at r2.
Reviewable status: 0 of 1 approvals obtained (waiting on @caisq and @nsthorat)
src/io/browser_http.ts, line 51 at r2 (raw file):
this.fetchFunc = fetch; } else { assert(typeof fetchFunc === 'function', 'Not a proper fetch function.');
Consider adding "Must pass a function that matches the signature of [link to fetch docs on MDN]
src/io/browser_http_test.ts, line 1036 at r2 (raw file):
}); it('Subclassing BrowserHTTPRequest and overriding fetchFunc', async () => {
Update test string since not doing the subclassing
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 for the review!
Reviewable status:
complete! 1 of 1 approvals obtained (waiting on @tafsiri and @nsthorat)
src/io/browser_http.ts, line 51 at r2 (raw file):
Previously, tafsiri (Yannick Assogba) wrote…
Consider adding "Must pass a function that matches the signature of [link to fetch docs on MDN]
Done.
src/io/browser_http_test.ts, line 1036 at r2 (raw file):
Previously, tafsiri (Yannick Assogba) wrote…
Update test string since not doing the subclassing
Done.
Towards fixing tensorflow/tfjs#410
This change is