-
-
Notifications
You must be signed in to change notification settings - Fork 69
Disable deep watcher on $props #42
Disable deep watcher on $props #42
Conversation
@probil This is somewhat work in progress. Not sure what scope of changes you expect in this PR. I really like you approach to deep-watching described here: #27 (comment) I guess it also implies that component Few tests will also be a cool addition to that. Should I implement all of it in this PR, or open another one? |
Hi @romansp The scope of this PR is to fix I think you can simplify it a bit for now. const watchReactiveProp = key => function (newValue) {
const existingValue = this.moveable[key];
if (existingValue === newValue) return;
this.moveable[key] = newValue;
}
export default {
// ...
watch: {
draggable: watchReactiveProp('draggable'),
resizable: watchReactiveProp('resizable'),
scalable: watchReactiveProp('scalable'),
rotatable: watchReactiveProp('rotatable'),
warpable: watchReactiveProp('warpable'),
pinchable: watchReactiveProp('pinchable'),
origin: watchReactiveProp('origin'),
throttleDrag: watchReactiveProp('throttleDrag'),
throttleResize: watchReactiveProp('throttleResize'),
throttleScale: watchReactiveProp('throttleScale'),
throttleRotate: watchReactiveProp('throttleRotate'),
keepRatio: watchReactiveProp('keepRatio'),
}
} I'll merge and then we can figure out how to make it more maintainable |
Okay, I updated PR. Changed to something that's closer to #27 (comment). |
Remove |
}); | ||
|
||
const watchMoveableProps = () => MOVEABLE_PROPS.reduce((acc, prop) => { | ||
acc[prop] = watchReactiveProp(prop, true); |
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 don't think we need deep
here 🤔 There is only one prop that can be an array
But let it be.
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.
Absolutely agree, I decided to implement it in this way to accommodate for future upgrade to newer versions of Movable
, so we don't have to think about changes in underlying API.
Fixes #27.
This PR tries to mitigate issue by dropping
deep: true
from watcher and provides another way to handle props updates to be passed correctly toMoveable
instance.