-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
One App-Wide Layout and Load Function #2436
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
Comments
This seems like it's mostly a duplicate of #1165 and #2169, though one part of this request isn't a duplicate:
This part of the request is something I haven't seen in any other feature request, to the best of my knowledge. |
This is now possible with (rather advanced, don't freak out) usage of named layouts: /src/routes/
/__layout-app.svelte # your app-wide layout, holds components and `load()`ed data
/[email protected] # your default layout, goes inside app-wide layout `/__layout-app.svelte`
/[email protected] # an empty <slot/> layout, goes inside app-wide layout `/__layout-app.svelte`
/some/regular/page.svelte # goes inside layout `/[email protected]`
/some/random/[email protected] # goes inside reset layout `/[email protected]` |
Describe the problem
I am trying to load data only once per application instance. Just before the app is initialized. Current infrastructure suggests that I put this logic in the
load
funciton in the main__layout.svelte
. However, it's not ideal when I mix per-layout data and per-app data within one load function. Another issue occures when I am going back and forth beween some__layout
and__layout.reset
. Those per-app data get loaded again.Another problem is when I want to keep some components even when I use layout.reset. Notifications component, for example, which stays mounted even when I reset the parent layout.
Describe the proposed solution
I suggest creating one more file [maybe] called
__app.svelte
which will follow the same logic as__layout.svelte
but it will be available only once per app. Eithersrc/app.svelte
orsrc/routes/__app.svelte
.It will sit above all the layouts. Example:
Alternatives considered
Using root-level __layout, however breakes when some __layout.reset is accessed.
Importance
would make my life easier
Additional Information
No response
The text was updated successfully, but these errors were encountered: