Skip to content
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

Some quarantine refactor #441

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Rxbsxn
Copy link

@Rxbsxn Rxbsxn commented Apr 10, 2020

Hi,
I've refactored base utils, extracted some functionalities to separated functions to make everything consistent and readable.
Thanks!

Copy link
Contributor

@alexlafroscia alexlafroscia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Over-all, I think these changes look really good! I appreciate the formatting clean-up and like how you've broken things out into nice logical pieces.

Besides my suggestion about the types for the before and after hook, I think this would be a great addition!

Comment on lines 40 to 51
const combineOptions = (model: Model, payload: any, before: any, ajaxOptions: any) => {
const data = (before && before.call(model, payload)) || payload;
return assign(ajaxOptions || {}, { data });
}

const handleResponse = (model: Model, response: JSONValue, after: any) => {
if (after && !model.isDestroyed) {
return after.call(model, response);
}

return response;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about using a type for before and after that makes it clear that they are functions that should expect Model as the value for this and response as an argument? I think that might make the type definitions a bit more accurate (and useful!)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will try to use that type, it will be much more readable

@Rxbsxn
Copy link
Author

Rxbsxn commented Apr 22, 2020

@alexlafroscia I've added a type for before/after functions - I'm not 100 percent sure about them, please review that and give me some advices if you see that something can be improved. Maybe before and after functions should be mandatory so we can get rid of that part of code: responseCallback | undefined what do you think?

I'd implement a more information about returning values from functions because so I do not have an idea what should be returned value from the function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants