vue-meteor-tracker icon indicating copy to clipboard operation
vue-meteor-tracker copied to clipboard

What's the downside of Vue.config.meteor.freeze = true?

Open Herteby opened this issue 8 years ago • 9 comments
trafficstars

I tried setting it to true, and everything still updates as it should. But since it's not the default, I assume it must cause problems in some cases?

Herteby avatar Jun 15 '17 18:06 Herteby

The data returned is immutable and you have to clone it to modify it.

Akryum avatar Jun 15 '17 18:06 Akryum

Ah, but when would you want to modify something returned by Meteor? Wouldn't that be bad practice anyway? Since it would just get overridden when Meteor updates again. I'll keep it set to true then.

Herteby avatar Jun 15 '17 18:06 Herteby

Yes, that is what I would do.

Akryum avatar Jun 15 '17 18:06 Akryum

But is this checked anywhere by Vue?

mitar avatar Jul 09 '17 10:07 mitar

It gets checked by vue-meteor-tracker: https://github.com/meteor-vue/vue-meteor-tracker#freezing-data

Herteby avatar Jul 09 '17 10:07 Herteby

No, I found it. There is a check Object.isExtensible() in Vue code. I was searching for Vue.isFrozen.

mitar avatar Jul 09 '17 10:07 mitar

Ah, I thought you meant the Vue.config.meteor.freeze option 😛

Herteby avatar Jul 09 '17 10:07 Herteby

Is it possible to only freeze for example one meteor subscription? Or perhaps only set Vue.config.meteor.freeze = true; for one Vue component and not assign it globally?

dolle39 avatar Jul 21 '17 11:07 dolle39

You can freeze the data yourself in the update function.

Akryum avatar Jul 21 '17 11:07 Akryum