1 | ;
|
2 |
|
3 | /**
|
4 | * Loading store.
|
5 | * @kind class
|
6 | * @name Loading
|
7 | * @example <caption>Ways to `import`.</caption>
|
8 | * ```js
|
9 | * import { Loading } from 'graphql-react';
|
10 | * ```
|
11 | *
|
12 | * ```js
|
13 | * import Loading from 'graphql-react/public/Loading.js';
|
14 | * ```
|
15 | * @example <caption>Ways to `require`.</caption>
|
16 | * ```js
|
17 | * const { Loading } = require('graphql-react');
|
18 | * ```
|
19 | *
|
20 | * ```js
|
21 | * const Loading = require('graphql-react/public/Loading');
|
22 | * ```
|
23 | * @example <caption>Construct a new instance.</caption>
|
24 | * ```js
|
25 | * const loading = new Loading();
|
26 | * ```
|
27 | */
|
28 | module.exports = class Loading extends EventTarget {
|
29 | constructor() {
|
30 | super();
|
31 |
|
32 | /**
|
33 | * Loading store, keyed by [cache key]{@link CacheKey}. Multiple
|
34 | * [loading cache values]{@link LoadingCacheValue} for the same key are set
|
35 | * in the order they started.
|
36 | * @kind member
|
37 | * @name Loading#store
|
38 | * @type {object<CacheKey, Set<LoadingCacheValue>>}
|
39 | */
|
40 | this.store = {};
|
41 | }
|
42 | };
|
43 |
|
44 | /**
|
45 | * Signals the start of [loading a cache value]{@link LoadingCacheValue}. The
|
46 | * event name starts with the [cache key]{@link CacheKey}, followed by `/start`.
|
47 | * @kind event
|
48 | * @name Loading#event:start
|
49 | * @type {LoadingCacheValue}
|
50 | * @type {CustomEvent}
|
51 | * @prop {object} detail Event detail.
|
52 | * @prop {LoadingCacheValue} detail.loadingCacheValue Loading cache value that started.
|
53 | */
|
54 |
|
55 | /**
|
56 | * Signals the end of [loading a cache value]{@link LoadingCacheValue}; either
|
57 | * the loading finished and the [cache value]{@link CacheValue} was set, the
|
58 | * loading was aborted, or there was an error. The event name starts with the
|
59 | * [cache key]{@link CacheKey}, followed by `/end`.
|
60 | * @kind event
|
61 | * @name Loading#event:end
|
62 | * @type {CustomEvent}
|
63 | * @prop {object} detail Event detail.
|
64 | * @prop {LoadingCacheValue} detail.loadingCacheValue Loading cache value that ended.
|
65 | */
|