How to use the @bentley/imodeljs-quantity.FormatterSpec.create function in @bentley/imodeljs-quantity

To help you get started, we’ve selected a few @bentley/imodeljs-quantity examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github imodeljs / imodeljs / core / frontend / src / QuantityFormatter.ts View on Github external
protected async loadFormatSpecsForQuantityTypes(useImperial: boolean): Promise {
    const typeArray: QuantityType[] = [QuantityType.Length, QuantityType.Angle, QuantityType.Area, QuantityType.Volume, QuantityType.LatLong, QuantityType.Coordinate, QuantityType.Stationing, QuantityType.LengthSurvey, QuantityType.LengthEngineering];
    const activeMap = useImperial ? this._imperialFormatSpecsByType : this._metricFormatSpecsByType;
    activeMap.clear();

    for (const quantityType of typeArray) {
      const formatPromise = this.getFormatByQuantityType(quantityType, useImperial);
      const unitPromise = this.getUnitByQuantityType(quantityType);
      const [format, unit] = await Promise.all([formatPromise, unitPromise]);
      const spec = await FormatterSpec.create(format.name, format, this, unit);
      activeMap.set(quantityType, spec);
    }
    return Promise.resolve();
  }