lib/mixin.ts   A
last analyzed

Complexity

Total Complexity 3
Complexity/F 3

Size

Lines of Code 33
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 21
mnd 2
bc 2
fnc 1
dl 0
loc 33
ccs 32
cts 32
cp 1
rs 10
bpm 2
cpm 3
noi 0
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A mixin.ts ➔ created 0 20 3
1 1
import type { ComponentOptionsMixin, CreateComponentPublicInstance } from 'vue';
2 1
import { isFunction } from './utils';
3 1
4 1
/**
5 1
 * Mixin, to be used in options API
6 1
 * Can be used locally or registered globally using `mixin: true`
7 1
 */
8 1
const pageTitleMixin: ComponentOptionsMixin = {
9 1
  created(this: CreateComponentPublicInstance) {
10 7
    const { title } = this.$options;
11 7
12 7
    if (title === undefined) {
13 3
      return;
14 3
    }
15 3
16 3
    // allow use dinamic title system
17 7
    if (isFunction(title)) {
18 2
      this.$watch(
19 2
        () => title.call(this, this),
20 2
        (val: string) => {
21 3
          this.$setPageTitle(val);
22 3
        },
23 2
        { immediate: true }
24 2
      );
25 2
      return;
26 2
    }
27 2
28 2
    this.$setPageTitle(title);
29 2
  },
30 7
};
31 1
32
export { pageTitleMixin };
33