-
Notifications
You must be signed in to change notification settings - Fork 50
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
base: master
Are you sure you want to change the base?
Conversation
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.
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!
addon/utils/member-action.ts
Outdated
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; | ||
} |
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 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!)
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 will try to use that type, it will be much more readable
b8c46c8
to
efeacce
Compare
@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 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 |
Hi,
I've refactored base utils, extracted some functionalities to separated functions to make everything consistent and readable.
Thanks!