- Notifications
You must be signed in to change notification settings - Fork638
-
Some of our models have a lot of code in e.g. views and actions, and this results in large bundle sizes However, the only thing that "really needs to be eagerly loaded" are the actual types.model type Is there a way to lazily import the views, actions, and things like this? Thanks :) |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 2 comments 4 replies
-
Setting up views and actions on a model is a method call itself, so you could theoretically defer the call to Although depending on how you bundle things up, I don't think this will really improve your bundle size, since your code is still going to import them somewhere in the bundle. It may improve your app startup time if the models don't need those views and actions until later on at runtime. |
BetaWas this translation helpful?Give feedback.
All reactions
-
We have a really big single page app, but there are entire subtrees of the mobx-state-tree that are unused by 99% of our users, so those would be good to lazy load
trying to think of where that elsewhere could be... my kneejerk is like "could lazy loaded .views and .actions be chained onto an instance of a model"? not sure if that would be doable...can keep brainstorming but ideas/codesandbox welcome |
BetaWas this translation helpful?Give feedback.
All reactions
-
also just for fun, our app is open source. mobx-state-tree from the start :)https://jbrowse.org |
BetaWas this translation helpful?Give feedback.
All reactions
🎉 1
-
Yup, this is precisely what I mean. You can chain any number of |
BetaWas this translation helpful?Give feedback.
All reactions
-
would types.lazy apply?#2156 |
BetaWas this translation helpful?Give feedback.
All reactions
-
This would improve your runtime performance so models don't go through their instantiation phase until after some asynchronous code has completed. |
BetaWas this translation helpful?Give feedback.