Skip to content
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

MdlScreenSizeService is destroyed on MdlLayoutComponent destroy #973

Closed
mscudlik opened this issue May 25, 2017 · 2 comments
Closed

MdlScreenSizeService is destroyed on MdlLayoutComponent destroy #973

mscudlik opened this issue May 25, 2017 · 2 comments

Comments

@mscudlik
Copy link

Hello Michael,

unfortunately i came accross another issue:

In the MdlLayoutComponent's onDestroy() the MdlScreensizeService is destroyed and because it is a singleton the layout breaks if you go back from a different page not using mdllayout:

mdl

This is also valid if you have multiple instances of MdlLayout on different pages. As soon as you leave the first instance the service is destroyed and the second instance doesn't work properly anymore.
The only workaround is to provide the MdlScreenSizeService in the components using MdlLayout which leads to multiple instances which costs some performance.

In addition, the MdlScreenSIzeService is not usable as API as its state depends on the Layouts Lifecycle.

You have two options:

  • Provide the service in mdllayout component so that a new instance is created every time. The downside is that the service cannot be used as API
  • Remove the destruction of the service and provide it as singleton. The downside is that it might unnessesarily listen to the media query if users dont use mdllayout at all

I have created a sample project to demonstrate the issue:

https://github.com/mscu/mdl-layout

Thanks a lot and best regards
Matthias

@mseemann
Copy link
Owner

hi. thx for finding this. i think the second option is the right one.

@mscudlik
Copy link
Author

Thnaks a lot for the quick fix :)

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

No branches or pull requests

2 participants