-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
data-dc-ondemand attribute #3
Comments
Looks really feasible from my point of view. |
@danilDelete Original idea was about attribute which is not connected to any of your component. In my example, data-dc-ondemand is not on data-dc-gmap component element it is on its parent. So you can have any number of components within that modal and none of them will be created with demand=false init call. Also data-dc-ondemand is a part of the dcFactory and relates to a searching and creation process, whereas options (data-dc-{namespace}={options}) is a part of component instance itself so anyway I would rather not to mix them within a single options object |
It can be good choice. I think |
@dubaua Yes, lazy makes sense to me as well as ondemand which is widely used name for something that shouldn't do any work until it is directly called. UPD: I've created a poll in the original post |
Do you guys have any thoughts about the default value of that withLazy/demand argument in dcFactory.init(element, withLazy/demand)? To be honest, I am not sure which one should be taken. We can implement any of them and see how it suits us |
Sometimes in you markup you have components which don't immediately visible for users. Maybe they are within tooltips/modals or you have a tabs component and only one will be shown to user. Simply speaking those cases require specific action to make some components visible and interactive.
Current factory will instantiate those components anyway because it doesn't know about their visibility and your UI logic.
If you have many of those hidden components you can end up with performance problems despite visually there are not many components on the page.
To address this we could introduce additional data attribute which can flag that a particular node and its children should be ignored during initialization phase. Then the only way to instantiate them would to call dcFactory.init with additional flag to indicate that all components including ignored should be created.
Example:
With described logic in place only modal-trigger component will be created on first dcFactory.init() call. Map component within modal will not because of data-dc-ondemand attribute. When button is clicked and Modal.create() is called then gmap component will be created.
Pros: components that are not needed right away won't be created so it is good for the performance.
Cons:
Possible variations of naming and default value:
The text was updated successfully, but these errors were encountered: