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

feat(): includeDefaultValues arg #7719

Closed
wants to merge 23 commits into from
Closed

Conversation

ShaMan123
Copy link
Contributor

@ShaMan123 ShaMan123 commented Feb 20, 2022

Support accepting includeDefaultValues as an argument to toObject methods instead of fussing with object.includeDefaultValues

I have been wanting this for a long time
I think we should drop includeDefaultValues as a prop on the object/canvas level
And I think excludeFromExport can go away as well if we accept a filter function

toObject(props, includeDefaultValues, filter) {
// for each object
filter(obj) ? 'include': 'exclude'
}

@asturur
Copy link
Member

asturur commented Feb 20, 2022

Shachar the PR descriptions do not match up the quality and quantity of work you are doing.
To understand what you want to do i need to read the code, and that ( because how my brain works ) makes me distracted with the code instead of the purpose of the code.

I did not ready the code yet, i would like the default behaviour was to not include default values all the time, because that creates enormous object dumps that are often not useful.
It also makes the prototype changes less effective when restoring such object states.

includeDefaultValues for me can be either at canvas level, library level, i agree that at object level is not that much useful.
It can also be an argument of the function toObject as you did, that is good too.
I'm ok dumping it as a property.

In general i prefer a single argument in the form of object compared to many arguments, with modern js is easier to handle.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 20, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   83.26 |    76.75 |   86.56 |   82.99 |                                               
 fabric.js |   83.26 |    76.75 |   86.56 |   82.99 | ...,29692,29817,29897-29962,30085,30184,30401 
-----------|---------|----------|---------|---------|-----------------------------------------------

@ShaMan123
Copy link
Contributor Author

@asturur I think includeDefaultValues should be false as default as well. It's very strange to put default as true.
How to move forward? Shall we dump this property? I think it's entirely redundant now because once you call toObject you simply pass true as follows toObject(undefined, true)
Sorry for not explaining, will do next time.

@ShaMan123
Copy link
Contributor Author

ShaMan123 commented Feb 20, 2022

In general i prefer a single argument in the form of object compared to many arguments, with modern js is easier to handle.

You mean toObject({ includeDefaultValues: true, propertiesToInclude: ['stroke'] })?
That's good

@asturur
Copy link
Member

asturur commented Feb 20, 2022

In general i prefer a single argument in the form of object compared to many arguments, with modern js is easier to handle.

You mean toObject({ includeDefaultValues: true, propertiesToInclude: ['stroke'] })? That's good

Yes but when we have es6/TS we can think of change this shape.

@asturur
Copy link
Member

asturur commented Feb 20, 2022

For me you can move forward.
let's keep the separated arguments, get rid of the property everywhere, and let's have it as a false as default.
That will also avoid to need to check if is boolean or undefined.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 20, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   83.31 |    76.79 |   86.56 |   83.04 |                                               
 fabric.js |   83.31 |    76.79 |   86.56 |   83.04 | ...,29692,29817,29897-29962,30085,30184,30401 
-----------|---------|----------|---------|---------|-----------------------------------------------

@ShaMan123
Copy link
Contributor Author

@asturur what type of object is this?

image: this.image && this.image.toObject(),

I am trying to figure out if to pass down the serialization args to it as well

@ShaMan123
Copy link
Contributor Author

ShaMan123 commented Feb 20, 2022

Finally all tests are passing. It was horrible...

@github-actions
Copy link
Contributor

github-actions bot commented Feb 20, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   83.27 |     76.7 |   86.55 |      83 |                                               
 fabric.js |   83.27 |     76.7 |   86.55 |      83 | ...,29654,29779,29859-29924,30047,30146,30363 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Feb 20, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   83.21 |    76.63 |   86.55 |   82.94 |                                               
 fabric.js |   83.21 |    76.63 |   86.55 |   82.94 | ...,29654,29779,29859-29924,30047,30146,30363 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Feb 20, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   83.27 |     76.7 |   86.55 |      83 |                                               
 fabric.js |   83.27 |     76.7 |   86.55 |      83 | ...,29654,29779,29859-29924,30047,30146,30363 
-----------|---------|----------|---------|---------|-----------------------------------------------

@stale
Copy link

stale bot commented Mar 13, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Issue marked as stale by the stale bot label Mar 13, 2022
@ShaMan123 ShaMan123 removed the stale Issue marked as stale by the stale bot label Mar 14, 2022
@ShaMan123
Copy link
Contributor Author

Will die out if/once removeDefaultValues is gone

@ShaMan123 ShaMan123 closed this Sep 14, 2022
@ShaMan123 ShaMan123 deleted the include-default-values branch September 14, 2022 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants