Skip to content
This repository has been archived by the owner on Dec 13, 2019. It is now read-only.

auto generated mains.js #61

Closed
mchikhaoui opened this issue Feb 22, 2018 · 14 comments
Closed

auto generated mains.js #61

mchikhaoui opened this issue Feb 22, 2018 · 14 comments

Comments

@mchikhaoui
Copy link

Hi Guys,
Thanks for the greate work tha you made !
I think that autogenerated main.js is not always a good idea because sometimes we need to make business logic in.

@rstoenescu
Copy link
Member

Hi. Thx. That's where App Plugins come into place. http://quasar-framework.org/guide/app-plugins.html

@mchikhaoui
Copy link
Author

Plugins can't stop application starting

promise().then(resp => new Vue ....).catch(err => redirect ....)

as well sometime we need to use Instance Lifecycle Hooks ...
Anyway, that will be good if we have choice to use or not plugins instead of main.js.

Thanks

@rstoenescu
Copy link
Member

You got app param in the export of a plugin. That's the root Vue component. You can use lifecycle hooks there. Also, not doing anything while the promise is resolved is bad UI.

1 similar comment
@rstoenescu
Copy link
Member

You got app param in the export of a plugin. That's the root Vue component. You can use lifecycle hooks there. Also, not doing anything while the promise is resolved is bad UI.

@trenoncourt
Copy link

Hi,
For my use, I need to redirect the user to another site (with msal). I do not want the user to see the site if he is not authenticated. It is possible to hook the created event with app but not to stop it (I think). This may cause the user to see the page briefly.

I can use a hack like that, but I don't think it's the best practice:

<div id="q-app" v-if="loaded">
    <router-view />
  </div>

@rstoenescu
Copy link
Member

Did you considered configuring the webserver to auto-redirect if user is not authenticated?

@trenoncourt
Copy link

For my use it is msal which handle that (https://github.com/AzureAD/microsoft-authentication-library-for-js) :/

@mchikhaoui
Copy link
Author

There is many other cases than authentication where we need to have full control of application entry point.
For me the best solution is to have a choice always.

Thanks

@rstoenescu
Copy link
Member

There's going to be a special "boot" plugin in 0.15.6 where can you can make decisions whether to call new Vue(app) or not.

@trenoncourt
Copy link

Thanks for that, it will help me à lot 😍

@rstoenescu
Copy link
Member

Available through Quasar CLI v0.15.7

@mchikhaoui
Copy link
Author

@rstoenescu Thanks for that, good decision;)

@rstoenescu
Copy link
Member

I actually hate it. I can almost see that boot plugin being misused...

@rstoenescu
Copy link
Member

I hope people understand this is not a replacement for main.js and read the docs on it carefully.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants