logo

Status

The Status class manages the status of anything that can have a 4-state status: idle, pending, success, error.

Properties

  • data (Map<string, string>): The Map that stores the status of each key. Each key is a string and each value is a string representing the status.
  • transformer (StatusTransformer): The function that transforms the keys before storing them in the Map. It’s used to standardize the keys.

Methods

  • isIdle(…keys: string[]): boolean: Checks if the status of the given keys is idle.
  • isPending(…keys: string[]): boolean: Checks if the status of the given keys is pending.
  • isSuccess(…keys: string[]): boolean: Checks if the status of the given keys is success.
  • isError(…keys: string[]): boolean: Checks if the status of the given keys is error.
  • isEveryIdle(…keys: string[][]): boolean: Checks if the status of every given key is idle.
  • isEveryPending(…keys: string[][]): boolean: Checks if the status of every given key is pending.
  • isEverySuccess(…keys: string[][]): boolean: Checks if the status of every given key is success.
  • isEveryError(…keys: string[][]): boolean: Checks if the status of every given key is error.
  • areSomeIdle(…keys: string[][]): boolean: Checks if the status of some given key is idle.
  • areSomePending(…keys: string[][]): boolean: Checks if the status of some given key is pending.
  • areSomeSuccess(…keys: string[][]): boolean: Checks if the status of some given key is success.
  • areSomeError(…keys: string[][]): boolean: Checks if the status of some given key is error.

Usage

This is an example of how to use the Status class.

import { Status } from '@aracna/core';

const status = new Status();

status.idle('t1');

// will log true
console.log(status.isIdle('t1'));

status.pending('t2');

// will log true
console.log(status.isPending('t2'));

// will log true
console.log(status.areSomeIdle('t1', 't2'));

// will log true
console.log(status.areSomePending('t1', 't2'));

status.pending('t1');

// will log true
console.log(status.isPending('t1'));

// will log false
console.log(status.isEveryIdle('t1', 't2'));

// will log true
console.log(status.isEveryPending('t1', 't2'));