diff options
| author | HJ <30-hj@users.noreply.git.pleroma.social> | 2022-03-31 17:45:29 +0000 |
|---|---|---|
| committer | HJ <30-hj@users.noreply.git.pleroma.social> | 2022-03-31 17:45:29 +0000 |
| commit | f71f101fce21ec053d46556928393a5f05f16239 (patch) | |
| tree | 7b880c9c76502c57d455e81a8477e273d8178049 /src/services/resettable_async_component.js | |
| parent | 1d1ea7e703891ec48dfcbd2fc8090656cef1e36a (diff) | |
| parent | afdc61b9b7088f5d9880a4a8466461bd8c5aeb78 (diff) | |
Merge branch 'vue3-again' into 'develop'
Migration to Vue 3 (again)
See merge request pleroma/pleroma-fe!1385
Diffstat (limited to 'src/services/resettable_async_component.js')
| -rw-r--r-- | src/services/resettable_async_component.js | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/services/resettable_async_component.js b/src/services/resettable_async_component.js index 517bbd88..1c046ce7 100644 --- a/src/services/resettable_async_component.js +++ b/src/services/resettable_async_component.js @@ -1,4 +1,4 @@ -import Vue from 'vue' +import { defineAsyncComponent, shallowReactive, h } from 'vue' /* By default async components don't have any way to recover, if component is * failed, it is failed forever. This helper tries to remedy that by recreating @@ -8,23 +8,21 @@ import Vue from 'vue' * actual target component itself if needs to be. */ function getResettableAsyncComponent (asyncComponent, options) { - const asyncComponentFactory = () => () => ({ - component: asyncComponent(), + const asyncComponentFactory = () => () => defineAsyncComponent({ + loader: asyncComponent, ...options }) - const observe = Vue.observable({ c: asyncComponentFactory() }) + const observe = shallowReactive({ c: asyncComponentFactory() }) return { - functional: true, - render (createElement, { data, children }) { + render () { // emit event resetAsyncComponent to reloading - data.on = {} - data.on.resetAsyncComponent = () => { - observe.c = asyncComponentFactory() - // parent.$forceUpdate() - } - return createElement(observe.c, data, children) + return h(observe.c(), { + onResetAsyncComponent () { + observe.c = asyncComponentFactory() + } + }) } } } |
