refactor(runtime-core): rename createAsyncComponent to defineAsyncComponent (#888)

BREAKING CHANGE: `createAsyncComponent` has been renamed to `defineAsyncComponent` for consistency with `defineComponent`.
This commit is contained in:
Cédric Exbrayat
2020-03-26 16:59:54 +01:00
committed by GitHub
parent 6a65739f61
commit ebc587376c
5 changed files with 38 additions and 38 deletions

View File

@@ -22,7 +22,7 @@ describe('Suspense', () => {
})
// a simple async factory for testing purposes only.
function createAsyncComponent<T extends ComponentOptions>(
function defineAsyncComponent<T extends ComponentOptions>(
comp: T,
delay: number = 0
) {
@@ -42,7 +42,7 @@ describe('Suspense', () => {
}
test('fallback content', async () => {
const Async = createAsyncComponent({
const Async = defineAsyncComponent({
render() {
return h('div', 'async')
}
@@ -70,7 +70,7 @@ describe('Suspense', () => {
test('nested async deps', async () => {
const calls: string[] = []
const AsyncOuter = createAsyncComponent({
const AsyncOuter = defineAsyncComponent({
setup() {
onMounted(() => {
calls.push('outer mounted')
@@ -79,7 +79,7 @@ describe('Suspense', () => {
}
})
const AsyncInner = createAsyncComponent(
const AsyncInner = defineAsyncComponent(
{
setup() {
onMounted(() => {
@@ -118,7 +118,7 @@ describe('Suspense', () => {
})
test('onResolve', async () => {
const Async = createAsyncComponent({
const Async = defineAsyncComponent({
render() {
return h('div', 'async')
}
@@ -221,7 +221,7 @@ describe('Suspense', () => {
})
test('content update before suspense resolve', async () => {
const Async = createAsyncComponent({
const Async = defineAsyncComponent({
setup(props: { msg: string }) {
return () => h('div', props.msg)
}
@@ -321,7 +321,7 @@ describe('Suspense', () => {
const toggle = ref(true)
const unmounted = jest.fn()
const Async = createAsyncComponent({
const Async = defineAsyncComponent({
setup() {
onUnmounted(unmounted)
return () => h('div', 'async')
@@ -360,7 +360,7 @@ describe('Suspense', () => {
const mounted = jest.fn()
const unmounted = jest.fn()
const Async = createAsyncComponent({
const Async = defineAsyncComponent({
setup() {
onMounted(mounted)
onUnmounted(unmounted)
@@ -400,7 +400,7 @@ describe('Suspense', () => {
test('nested suspense (parent resolves first)', async () => {
const calls: string[] = []
const AsyncOuter = createAsyncComponent(
const AsyncOuter = defineAsyncComponent(
{
setup: () => {
onMounted(() => {
@@ -412,7 +412,7 @@ describe('Suspense', () => {
1
)
const AsyncInner = createAsyncComponent(
const AsyncInner = defineAsyncComponent(
{
setup: () => {
onMounted(() => {
@@ -466,7 +466,7 @@ describe('Suspense', () => {
test('nested suspense (child resolves first)', async () => {
const calls: string[] = []
const AsyncOuter = createAsyncComponent(
const AsyncOuter = defineAsyncComponent(
{
setup: () => {
onMounted(() => {
@@ -478,7 +478,7 @@ describe('Suspense', () => {
10
)
const AsyncInner = createAsyncComponent(
const AsyncInner = defineAsyncComponent(
{
setup: () => {
onMounted(() => {
@@ -568,7 +568,7 @@ describe('Suspense', () => {
const msg = ref('nested msg')
const calls: number[] = []
const AsyncChildWithSuspense = createAsyncComponent({
const AsyncChildWithSuspense = defineAsyncComponent({
setup(props: { msg: string }) {
onMounted(() => {
calls.push(0)
@@ -581,7 +581,7 @@ describe('Suspense', () => {
}
})
const AsyncInsideNestedSuspense = createAsyncComponent(
const AsyncInsideNestedSuspense = defineAsyncComponent(
{
setup(props: { msg: string }) {
onMounted(() => {
@@ -593,7 +593,7 @@ describe('Suspense', () => {
20
)
const AsyncChildParent = createAsyncComponent({
const AsyncChildParent = defineAsyncComponent({
setup(props: { msg: string }) {
onMounted(() => {
calls.push(1)
@@ -602,7 +602,7 @@ describe('Suspense', () => {
}
})
const NestedAsyncChild = createAsyncComponent(
const NestedAsyncChild = defineAsyncComponent(
{
setup(props: { msg: string }) {
onMounted(() => {
@@ -692,13 +692,13 @@ describe('Suspense', () => {
test('new async dep after resolve should cause suspense to restart', async () => {
const toggle = ref(false)
const ChildA = createAsyncComponent({
const ChildA = defineAsyncComponent({
setup() {
return () => h('div', 'Child A')
}
})
const ChildB = createAsyncComponent({
const ChildB = defineAsyncComponent({
setup() {
return () => h('div', 'Child B')
}