Skip to content

Commit 23cdbb1

Browse files
committed
perf(resource-manager): 替换使用warning包
affects: @vue-async/resource-manager
1 parent 29b42fc commit 23cdbb1

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

packages/resource-manager/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@
3939
"url": "https://github.com/aceHubert/vue-async/issues"
4040
},
4141
"dependencies": {
42-
"@vue-async/utils": "^1.1.0"
42+
"@vue-async/utils": "^1.1.0",
43+
"warning": "^4.0.3"
4344
},
4445
"devDependencies": {
4546
"@nuxt/types": "^2.14.6",
4647
"@nuxt/typescript-build": "^2.0.3",
48+
"@types/warning": "^3.0.0",
4749
"nuxt": "^2.14.6",
4850
"vue-class-component": "^7.2.3",
4951
"vue-property-decorator": "^8.4.1",

packages/resource-manager/src/ability/Suspense.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Vue from 'vue';
2-
import { error } from '@vue-async/utils';
2+
import warning from 'warning';
33
import { pushSuspenseInstance, popSuspenseInstance, currentSuspenseInstance } from './currentInstance';
44

55
// Types
@@ -31,7 +31,7 @@ export const del = (asyncFactory: AsyncFactory, error?: any) => {
3131
export const add = (asyncFactory: AsyncFactory) => {
3232
const suspIns = currentSuspenseInstance || asyncFactory.suspenseInstance;
3333
if (!suspIns) {
34-
return error(process.env.NODE_ENV === 'production', 'No Suspense instance');
34+
return warning(process.env.NODE_ENV === 'production', 'No Suspense instance');
3535
}
3636
const asyncFactorys = suspIns.asyncFactorys || (suspIns.asyncFactorys = new Set());
3737

@@ -45,7 +45,7 @@ export const add = (asyncFactory: AsyncFactory) => {
4545
export const has = (asyncFactory: AsyncFactory) => {
4646
const suspIns = currentSuspenseInstance || asyncFactory.suspenseInstance;
4747
if (!suspIns) {
48-
return error(process.env.NODE_ENV === 'production', 'No Suspense instance');
48+
return warning(process.env.NODE_ENV === 'production', 'No Suspense instance');
4949
}
5050
return suspIns.asyncFactorys && suspIns.asyncFactorys.has(asyncFactory);
5151
};
@@ -90,7 +90,7 @@ export default Vue.extend({
9090
this.$on(RESOLVED, () => {
9191
this.destoryLoading();
9292
this.resolved = true;
93-
reslove();
93+
reslove(null);
9494
});
9595

9696
this.$on(REJECTED, (err: Error) => {

packages/resource-manager/src/ability/createResource.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Vue from 'vue';
2-
import { error } from '@vue-async/utils';
2+
import warning from 'warning';
33
import { del, add } from './Suspense';
44
import { currentInstance, currentSuspenseInstance, setCurrentInstance } from './currentInstance';
55
import findSuspenseInstance from './findSuspenseInstance';
@@ -83,8 +83,8 @@ export default function CreateResource<I = any, R = any, E = Error>(
8383
del(uniqueWrapFactory);
8484
}
8585
})
86-
.catch((err: E) => {
87-
error(process.env.NODE_ENV === 'production', (err as any).message);
86+
.catch((err) => {
87+
warning(process.env.NODE_ENV === 'production', err.message);
8888

8989
$res.$$error = options && options.onError ? options.onError(err) : err;
9090

packages/resource-manager/src/ability/lazy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Vue from 'vue';
2-
import { error } from '@vue-async/utils';
2+
import warning from 'warning';
33
import { del, add, has } from './Suspense';
44
import { currentSuspenseInstance } from './currentInstance';
55
import findSuspenseInstance from './findSuspenseInstance';
@@ -44,7 +44,7 @@ export default function Lazy<PropsDef = PropsDefinition<DefaultProps>>(
4444
this.$forceUpdate();
4545
})
4646
.catch((err) => {
47-
error(process.env.NODE_ENV === 'production', err);
47+
warning(process.env.NODE_ENV === 'production', err.message);
4848
del(asyncFactory, err);
4949
});
5050
},

0 commit comments

Comments
 (0)