changed dustpress.js to class format and added eslint configs#23
changed dustpress.js to class format and added eslint configs#23
Conversation
|
|
||
| this.instance.successHandler = ( data, textStatus, jqXHR ) => this.successHandler( data, textStatus, jqXHR ); | ||
| this.instance.errorHandler = ( jqXHR, textStatus, errorThrown ) => this.errorHandler( jqXHR, textStatus, errorThrown ); | ||
| this.instance.uploadProgressHandler = ( event ) => this.uploadDownloadProgressHandler( event ); |
There was a problem hiding this comment.
I am not sure if this will cause events to collide if two requests are performed simultaneously. The issue here might be that the methods are now a part of the DustPress class, not the instance created request instance itself.
Have you tested this and if so, could you clarify how this changed format ensures instance uniqueness compared to the old implementation?
…to class-format
…uest helper class
villesiltala
left a comment
There was a problem hiding this comment.
Great updates! 👍 Take a look at a couple of questions in the request class.
|
|
||
| this.params.start(); | ||
|
|
||
| this.params.successHandler = ( data, textStatus, jqXHR ) => this.successHandler( data, textStatus, jqXHR ); |
There was a problem hiding this comment.
What is the purpose of recreating these methods under the "params" key? I can't see the need for this since the methods are already accessible under the same scope. If you're thinking the class methods are not confined to a single object, I believe it is not the case. Each request instance should have its own methods which can be referenced safely for instance by assigning them as event handlers.
| this.params.downloadProgressHandler = ( event ) => this.uploadDownloadProgressHandler( event ); | ||
|
|
||
| return $.ajax( options ) | ||
| .done( ( data, textStatus, jqXHR ) => this.params.successHandler( data, textStatus, jqXHR ) ) |
There was a problem hiding this comment.
Referring to my comment above, why can't this just be:
.done( ( data, textStatus, jqXHR ) => this.successHandler( data, textStatus, jqXHR ) )
this.successHandler here refers to a method of an instance since it is not static. Thus it should be the same thing as using this.params.successHandler.
| * @param {object} parsed Parsed data. | ||
| */ | ||
| addToDebugger( parsed ) { | ||
| delete this.params.params.success; |
There was a problem hiding this comment.
Where could these come from and why are they removed here?
No description provided.