Skip to content

Don't initialize $lazy meteor props - #61

Open
red-meadow wants to merge 1 commit into
meteor-vue:masterfrom
red-meadow:patch-2
Open

Don't initialize $lazy meteor props#61
red-meadow wants to merge 1 commit into
meteor-vue:masterfrom
red-meadow:patch-2

Conversation

@red-meadow

@red-meadow red-meadow commented Nov 1, 2019

Copy link
Copy Markdown

Fixes #49 (partially)
Fixes #52

For now, meteor properties marked as $lazy are not really lazy, because the functions are executed at least once in order to fill vm.$data.$meteor.data with initial values. It seems impossible to completely prevent execution without workarounds.

This PR proposes to get rid of values initialization at all. Defined meteor properties will be still proxied and therefore available in the component and template with undefined values. Running this.$startMeteor() will add actual values.

I understand that this change may easily breaks many existing apps based on the current $lazy behavior. A possible alternative is adding another special property to meteor object, like $noInit or something similar. Developer then can use both $lazy and $noInit or stay with the first one. Or, let's say, $veryLasy property which does the whole job. I can create a PR with this functionality.

@tennox

tennox commented Apr 11, 2020

Copy link
Copy Markdown

Caused by this fix for #34 and #38.

@red-meadow

red-meadow commented Apr 11, 2020

Copy link
Copy Markdown
Author

Thanks!
I saw that commit though I didn't pay attention to what issues it closed.
Have you tested the new code and encountered any issues with watchers or computed properties? Because for me everything works fine with both enabled and disabled $lazy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

$lazy: true causing Error in beforeCreate hook: "TypeError: Cannot read property '***' of undefined" Meteor properties over reactive?

2 participants