Open hallipr opened 1 month ago
Internal mutation is ok and is important for performance; these mutations in Luxon are just memoization. I think the issue is that we're not hiding it from Vue; i.e. Luxon's objects are immutable as far as the API is concerned, but Vue is seeing that notionally private members on the Duration object are changing, and it has no way to know they aren't part of an API. How does Vue detect mutations, and what's the supported way to hide things from it? This is supposed to be a tree-falls-in-the-woods sort of thing.
The gist here is that I'm willing to make changes that better support tools like Vue, but not at the expense of performance.
You're likely looking for shallowReactive.
Describe the bug Because Duration.toFormat mutates the Duration, this causes recursive updates in Vue for components that run toFormat on Duration properties getters.
To Reproduce with:
when I:
I get:
But I also get
Actual vs Expected behavior I would expect toFormat to not mutate the duration, but it does and this is detected by Vue.
Desktop (please complete the following information):
Additional context
This is another effect of the cause from https://github.com/moment/luxon/issues/1104
I originally posted this as a StackOverflow question https://stackoverflow.com/questions/78474017