UNPKG

graphql-react

Version:

A GraphQL client for React using modern context and hooks APIs that’s lightweight (< 4 kB) but powerful; the first Relay and Apollo alternative with server side rendering.

52 lines (48 loc) 1.57 kB
/** * Loading store. * @kind class * @name Loading * @example <caption>How to import.</caption> * ```js * import Loading from "graphql-react/Loading.mjs"; * ``` * @example <caption>Construct a new instance.</caption> * ```js * const loading = new Loading(); * ``` */ export default class Loading extends EventTarget { constructor() { super(); /** * Loading store, keyed by [cache key]{@link CacheKey}. Multiple * [loading cache values]{@link LoadingCacheValue} for the same key are set * in the order they started. * @kind member * @name Loading#store * @type {object<CacheKey, Set<LoadingCacheValue>>} */ this.store = {}; } } /** * Signals the start of [loading a cache value]{@link LoadingCacheValue}. The * event name starts with the [cache key]{@link CacheKey}, followed by `/start`. * @kind event * @name Loading#event:start * @type {LoadingCacheValue} * @type {CustomEvent} * @prop {object} detail Event detail. * @prop {LoadingCacheValue} detail.loadingCacheValue Loading cache value that started. */ /** * Signals the end of [loading a cache value]{@link LoadingCacheValue}; either * the loading finished and the [cache value]{@link CacheValue} was set, the * loading was aborted, or there was an error. The event name starts with the * [cache key]{@link CacheKey}, followed by `/end`. * @kind event * @name Loading#event:end * @type {CustomEvent} * @prop {object} detail Event detail. * @prop {LoadingCacheValue} detail.loadingCacheValue Loading cache value that ended. */