import { atomFamily } from 'recoil';

/**
 * The `multiSourceMetadata` atom family keeps track of all of the loaded
 * backend data sources that can provide a value for a particular "atom". It
 * stores the location of the source as well as metadata like when the data
 * source was last updated. This provides the information necessary for the
 * `multiSourceSelector` to figure out which is the most recently updated
 * source of a particular atom and return the correct value.
 *
 * ```
 * [
 *   {
 *     key: string,
 *     lastUpdated: number,
 *   },
 * ]
 * ```
 */
const multiSourceMetadata = atomFamily({
  key: 'int-style.election.atoms.multiSourceMetadata',
  default: []
});
export default multiSourceMetadata;