• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ecamp / hal-json-vuex / 14422895806

12 Apr 2025 07:59PM UTC coverage: 93.432%. Remained the same
14422895806

push

github

usu
3.0.0-alpha.10

160 of 183 branches covered (87.43%)

Branch coverage included in aggregate %.

281 of 289 relevant lines covered (97.23%)

930.78 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.91
/src/storeModule.ts
1
import { del, set } from 'vue-demi'
2

3
import type { MutationTree } from 'vuex/types'
4

5
import type StoreData from './interfaces/StoreData'
6

7
export const state = {}
9✔
8
export type State<StoreType> = Record<string, StoreData<StoreType>>
9

10
export const mutations: MutationTree<State<unknown>> = {
9✔
11
  /**
12
   * Adds a placeholder into the store that indicates that the entity with the given URI is currently being
13
   * fetched from the API and not yet available.
14
   * @param state Vuex state
15
   * @param uri   URI of the object that is being fetched
16
   */
17
  addEmpty<StoreType> (state: State<StoreType>, uri: string) : void {
18
    set(state, uri, { _meta: { self: uri, loading: true } })
648✔
19
  },
20
  /**
21
   * Adds entities loaded from the API to the Vuex store.
22
   * @param state Vuex state
23
   * @param data  An object mapping URIs to entities that should be merged into the Vuex state.
24
   */
25
  add<StoreType> (state: State<StoreType>, data: Record<string, unknown>) : void {
26
    Object.keys(data).forEach(uri => {
762✔
27
      set(state, uri, data[uri])
1,335✔
28

29
      set(state[uri]._meta, 'loading', false)
1,335✔
30
      set(state[uri]._meta, 'reloading', false)
1,335✔
31
    })
32
  },
33
  /**
34
   * Marks a single entity in the Vuex store as reloading, meaning a reloading network request is currently ongoin.
35
   * @param state Vuex state
36
   * @param uri   URI of the entity that is currently being reloaded
37
   */
38
  reloading<StoreType> (state: State<StoreType>, uri: string) : void {
39
    if (state[uri]) set(state[uri]._meta, 'reloading', true)
150!
40
  },
41
  /**
42
   * Marks a single entity in the Vuex store as normal again, after it has been marked as reloading before.
43
   * @param state Vuex state
44
   * @param uri   URI of the entity that is currently being reloaded
45
   */
46
  reloadingFailed<StoreType> (state: State<StoreType>, uri: string) : void {
47
    if (state[uri]) set(state[uri]._meta, 'reloading', false)
36✔
48
  },
49
  /**
50
   * Removes a single entity from the Vuex store.
51
   * @param state Vuex state
52
   * @param uri   URI of the entity to be removed
53
   */
54
  purge<StoreType> (state: State<StoreType>, uri: string) : void {
55
    del(state, uri)
135✔
56
  },
57
  /**
58
   * Removes all entities from the Vuex store.
59
   * @param state Vuex state
60
   * @param uri   URI of the entity to be removed
61
   */
62
  purgeAll<StoreType> (state: State<StoreType>) : void {
63
    Object.keys(state).forEach(uri => {
12✔
64
      del(state, uri)
24✔
65
    })
66
  },
67
  /**
68
   * Marks a single entity in the Vuex store as deleting, meaning the process of deletion is currently ongoing.
69
   * @param state Vuex state
70
   * @param uri   URI of the entity that is currently being deleted
71
   */
72
  deleting<StoreType> (state: State<StoreType>, uri: string) : void {
73
    if (state[uri]) set(state[uri]._meta, 'deleting', true)
129✔
74
  },
75
  /**
76
   * Marks a single entity in the Vuex store as normal again, after it has been marked as deleting before.
77
   * @param state Vuex state
78
   * @param uri   URI of the entity that failed to be deleted
79
   */
80
  deletingFailed<StoreType> (state: State<StoreType>, uri: string) : void {
81
    if (state[uri]) set(state[uri]._meta, 'deleting', false)
6!
82
  }
83
}
84

85
export default {
86
  mutations
87
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc