-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
MAJOR feat(fabric) remove callbacks in for Promise support #7657
Conversation
onLoaded(); | ||
enlivenObjects: function(objects, namespace, reviver) { | ||
return Promise.all(objects.map(function(obj) { | ||
var klass = fabric.util.getKlass(obj.type, namespace); |
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.
if we find a nice solution for filters, namespace can go away
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.
YES! Go away namespace (continuing previous comment)
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.
And when it goes away I hope it takes it's friend fabric.util.getKlass
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.
same here regarding passing klass
instead of namespace
@ShaMan123 @melchiar When i know it actually runs i will ask you to give a look. |
Holy shit this is major! |
on-behalf-of: @shutterstock <abogazzi@shutterstock.com>
on-behalf-of: @shutterstock <andreabogazzi79@gmail.com>
There is a little bit of changes here. So enliveObjectEnlivables can eventually wrap the options before you create an object, or you start from the fromObject method directly. Indeed i removed the setBackgroundImage, setOverlayImage.
From a developer persepctive seems reasonable to write something like that. |
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.
This PR looks awesome.
Makes the codebase much more readable and elegant and easy to use and override.
I have added comments.
The main things are:
- keeping customization in mind (e.g. introducing a param/mechanism to allow adding custom enlivened props with ease)
- drop namespaces altogether
- be consist in dropping callbacks - basically drop
_fromObject
as well
onLoaded(); | ||
enlivenObjects: function(objects, namespace, reviver) { | ||
return Promise.all(objects.map(function(obj) { | ||
var klass = fabric.util.getKlass(obj.type, namespace); |
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.
YES! Go away namespace (continuing previous comment)
onLoaded(); | ||
enlivenObjects: function(objects, namespace, reviver) { | ||
return Promise.all(objects.map(function(obj) { | ||
var klass = fabric.util.getKlass(obj.type, namespace); |
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.
And when it goes away I hope it takes it's friend fabric.util.getKlass
|
I think it is redundant - it doesn't do much but wrap the call to |
Well if it wraps if for 6-7 classes, is good enough. |
in theory both Line, Triangle, Rect, Polyline and Polygon can be just constructors that rely on the underlying fabric.Path. This is a long standing idea that was around, but we need to verify if the necessary setter/getter and code to make it still fill like the previous object is convenient compared to keep them separated |
Our deep extend had a different meaning compared to the lodash one. |
Code Coverage Summary
|
Code Coverage Summary
|
Code Coverage Summary
|
Code Coverage Summary
|
Code Coverage Summary
|
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.
Eraser is committed
I've pushed some minor JSDOC changes as well
- I want to change
enlivenObjects
not to usegetKlass
at all (we'll do that once we migrate js) - I do think we should consider wrapping the external methods of the svg parser with promises (and leave internals as is until you decide it's fate) in order to unify fabric. But it can wait.
Excellent job! This was a huge tedious effort.
Group is up!
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.
This is great. So much garbage removed!
@ShaMan123 we will solves svg before getting to next version, either wrapping or changing the parser. |
Code Coverage Summary
|
off i pushed away reviews because i addressed the text comment. |
Hello, is this feature available already, and in which version? Thanks |
v5+ |
Hi @ShaMan123 , thanks for the response. I just have a problem. After upgrading from |
Did you try building fabric as suggested in the issue you referenced? |
I tried rebuilding the fabric also, and the generated |
I see the version has somehow got mixed with outdated code. npm i --save github:fabricjs/fabric.js @asturur URGENT |
Thanks @ShaMan123 , that solves the issue on my side. Will wait for the next stable patch. |
closes #3684
Scope of changes:
fabric.Image functionalities
loadFromJSON, fromObject functionalities.
SVG hasn't be touched yet.
BREAKING:
Everything that was
is now
All places i found that take a string, enlive the content of the string and set the properties and accept a callback, have been removed, including:
The suggest replacements are:
fabric.Image.fromUrl(url).then((fabricImage => canvas.backgroundImage = fabricImage));
or use Pattern.fromObject for the pattern.
Those seems reasonbale changes for the sake of standardization.