-
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(data-loaders)!: rewrite of data loaders
BREAKING CHANGE: Data Loaders have been redesigned to be more flexible and account for other libraries. Notably, the caching behavior has been moved out of the basic loader to an extended one and the basic loader has no cache. All of the pending bugs have also been fixed. I recommend you to give the RFC examples a new read to get setup: https://uvr.esm.is/rfcs/data-loaders/. Most of the changes are simplifying things by removing them. Here is a list of the breaking changes to simplify migration: - The `dataFetching` option is no longer needed. - Manual work needed to add loaders with `HasDataLoaderMeta` has been removed. It is just no longer needed. Loaders are picked up from lazy loaded components and must otherwise be directly added to a `meta.loaders` array. See the example at https://uvr.esm.is/rfcs/data-loaders/#basic-example - The function `setupDataFetchingGuard` has been replaced with a Vue Plugin. See https://uvr.esm.is/rfcs/data-loaders/#data-loader-setup for details. - If you were relying on `cacheTime`, use the `staleTime` option in the new [`defineColadaLoader()`](https://uvr.esm.is/rfcs/data-loaders/colada) based off [@pinia/colada](https://github.com/posva/pinia-colada) - To reduce the dependency on file-based router, things have been refactored and none of the defineLoader functions are automatically imported anymore. You can add them yourself to the list of auto imports, or import them from `vue-router/auto`. The good news is you no longer need to use the plugin in order to benefit from the data loaders; they can be directly imported from `unplugin-vue-router/runtime`. If you find missing information or improvements, please open a Pull Request to improve the `CHANGELOG.md`.
- Loading branch information
Showing
20 changed files
with
33 additions
and
1,910 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
# `defineBasicLoader()` | ||
|
||
## Setup | ||
|
||
## Example | ||
|
||
## SSR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,5 @@ | ||
import { _setupDataFetchingGuard } from 'unplugin-vue-router/runtime' | ||
import { DataLoaderPlugin } from 'unplugin-vue-router/runtime' | ||
|
||
export default defineNuxtPlugin((nuxtApp) => { | ||
// console.log('going in!', useRouter()) | ||
const data = _setupDataFetchingGuard( | ||
useRouter(), | ||
process.client ? nuxtApp.payload._uvr : undefined | ||
) | ||
|
||
if (process.server) { | ||
nuxtApp.payload._uvr = data | ||
} | ||
|
||
useRouter() | ||
.isReady() | ||
.then(() => { | ||
console.log('READY!', nuxtApp.payload._uvr) | ||
}) | ||
// TODO: | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,11 +46,6 @@ class _TreeNodeValueBase { | |
private _overrides = new Map<string, RouteRecordOverride>() | ||
// TODO: cache the overrides generation | ||
|
||
/** | ||
* Should we add the loader guard to the route record. | ||
*/ | ||
includeLoaderGuard: boolean = false | ||
|
||
/** | ||
* View name (Vue Router feature) mapped to their corresponding file. By default, the view name is `default` unless | ||
* specified with a `@` e.g. `[email protected]` will have a view name of `aux`. | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.