Skip to content

Some quarantine refactor - #441

Open
Rxbsxn wants to merge 7 commits into
mike-north:masterfrom
Rxbsxn:some-quarantine-refactor
Open

Some quarantine refactor#441
Rxbsxn wants to merge 7 commits into
mike-north:masterfrom
Rxbsxn:some-quarantine-refactor

Conversation

@Rxbsxn

@Rxbsxn Rxbsxn commented Apr 10, 2020

Copy link
Copy Markdown

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

@alexlafroscia alexlafroscia left a comment

Copy link
Copy Markdown
Contributor

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 thread addon/utils/member-action.ts Outdated
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
Copy Markdown
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
Copy Markdown
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

Comment thread addon/utils/collection-action.ts Outdated
@Rxbsxn
Rxbsxn force-pushed the some-quarantine-refactor branch from b8c46c8 to efeacce Compare April 21, 2020 19:25
@Rxbsxn

Rxbsxn commented Apr 22, 2020

Copy link
Copy Markdown
Author

@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.

2 participants