-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Resource fixes #6211
Resource fixes #6211
Conversation
@tfili, thanks for the pull request! Maintainers, we have a signed CLA from @tfili, so you can review this at any time.
I am a bot who helps you make Cesium awesome! Contributions to my configuration are welcome. 🌍 🌎 🌏 |
var value = result[param]; | ||
var q2Value = q2[param]; | ||
if (defined(value)) { | ||
if (!Array.isArray(value)) { |
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.
Would it make things simpler to have the query properties always be arrays?
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.
Possibly, however we would need to change functionality of objectToQuery
and queryToObject
to do this. Then a user could still queryParameters
property and change it manually, so we'd have to implement a mechanism to prevent that. Since its already done I think it'll be more trouble than its worth.
Source/Core/Resource.js
Outdated
* | ||
* | ||
* @example | ||
* // Load a single resource asynchronously. In real code, you should use loadBlob instead. |
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.
What does In real code, you should use loadBlob instead
mean? Is that just a bad copy/paste? It's in the doc for the next few functions 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.
I think the answer is "both" 😄
Ge means that you wouldn't normally use fetch
to retrieve a blob, you would call the more specific fetchBlob
instead.
@tfili I would recommend deleting this comment and updating the comment paragraph above to say that we recommend using the more specific functions in the class, i.e. fetchJson, fetchImage, etc.. rather than calling fetch directly, but we expose this for the cases where the user does not want the data to be interested in anyway way. Then just rename blob in the below example to body
and we're good to go.
server.js
Outdated
@@ -55,7 +55,14 @@ | |||
app.use(function(req, res, next) { | |||
res.header('Access-Control-Allow-Origin', '*'); | |||
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept'); | |||
next(); | |||
//intercepts OPTIONS method | |||
if ('OPTIONS' === req.method) { |
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.
Is this still needed if we're just going to mock OPTIONS in the test? (If not I would remove it since people unfortunately use our code as a basis for their own server).
Source/Core/Resource.js
Outdated
/** | ||
* @private | ||
*/ | ||
function combineQueryParameters(q1, q2, preserveQueryParameters) { |
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.
Please add some comments about what this function is actually doing (i.e. perhaps just some examples of expected input/output behavior). The intent of these types of functions are a pain to figure out once you haven't looked at it in a while (or are seeing it for the first time).
Source/Core/Resource.js
Outdated
@@ -239,7 +278,10 @@ define([ | |||
*/ | |||
Resource.createIfNeeded = function(resource, options) { | |||
if (resource instanceof Resource) { | |||
return resource.clone(); | |||
// Keep existing request |
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.
Please expand this comment to explain why we are keeping it.
Source/Core/Resource.js
Outdated
* | ||
* | ||
* @example | ||
* // Load a single resource asynchronously. In real code, you should use loadBlob instead. |
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.
This one is definitely a copy and paste error, remove the commend and change blob
to body
(I assume DELETE returns the body without interpreting it at 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.
Nevermind, I read the doc, the example should definitely specify a response type (probably JSON) so that users see a real world use case.
I think that's all I have. Thanks @tfili |
I resolved the CHANGES conflict. @hpinkos this is good to me, please merge when you're happy. |
Thanks @tfili! |
Looks like we missed one, |
addQueryParameters
has been replaced withsetQueryParameters
andappendQueryParameters
.addTemplateValues
has been replaced withsetTemplateValues
for consistency.loadWithXhr
has been fixed to actually pass through the method. Even though it is deprecated, this was broken in the last release and can lead to weird bugs if a user was doing anything but a GET.Resource.clone
now functions as expected. Internal logic was moved into the private methodResource.createIfNeeded
.server.js
was modified to handleOPTIONS
requests, so it can be tested.