Skip to content

Files

Latest commit

 

History

History
37 lines (29 loc) · 932 Bytes

next-tick-style.md

File metadata and controls

37 lines (29 loc) · 932 Bytes

Pattern: Malformed Vue.nextTick/this.$nextTick

Issue: -

Description

Enforces whether the callback version or Promise version (which was introduced in Vue v2.1.0) should be used in Vue.nextTick and this.$nextTick.

<script>
import { nextTick as nt } from 'vue';

export default {
  async mounted() {
    /* ✓ GOOD */
    nt().then(() => callback());
    await nt(); callback();
    Vue.nextTick().then(() => callback());
    await Vue.nextTick(); callback();
    this.$nextTick().then(() => callback());
    await this.$nextTick(); callback();

    /* ✗ BAD */
    nt(() => callback());
    nt(callback);
    Vue.nextTick(() => callback());
    Vue.nextTick(callback);
    this.$nextTick(() => callback());
    this.$nextTick(callback);
  }
}
</script>

Further Reading