How to use the @superset-ui/core.makeSingleton function in @superset-ui/core

To help you get started, we’ve selected a few @superset-ui/core 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 apache-superset / superset-ui / packages / superset-ui-chart / src / registries / ChartBuildQueryRegistrySingleton.ts View on Github external
import { Registry, makeSingleton, OverwritePolicy } from '@superset-ui/core';
import { QueryContext } from '@superset-ui/query';

// Ideally this would be 
type BuildQuery = (formData: any) => QueryContext;

class ChartBuildQueryRegistry extends Registry {
  constructor() {
    super({ name: 'ChartBuildQuery', overwritePolicy: OverwritePolicy.WARN });
  }
}

const getInstance = makeSingleton(ChartBuildQueryRegistry);

export default getInstance;
github apache-superset / superset-ui / packages / superset-ui-chart / src / registries / ChartMetadataRegistrySingleton.ts View on Github external
import { Registry, makeSingleton, OverwritePolicy } from '@superset-ui/core';
import ChartMetadata from '../models/ChartMetadata';

class ChartMetadataRegistry extends Registry {
  constructor() {
    super({ name: 'ChartMetadata', overwritePolicy: OverwritePolicy.WARN });
  }
}

const getInstance = makeSingleton(ChartMetadataRegistry);

export default getInstance;
github apache-superset / superset-ui / packages / superset-ui-chart / src / registries / ChartTransformPropsRegistrySingleton.ts View on Github external
import { Registry, makeSingleton, OverwritePolicy } from '@superset-ui/core';
import { TransformProps } from '../types/TransformFunction';

class ChartTransformPropsRegistry extends Registry {
  constructor() {
    super({ name: 'ChartTransformProps', overwritePolicy: OverwritePolicy.WARN });
  }
}

const getInstance = makeSingleton(ChartTransformPropsRegistry);

export default getInstance;
github apache-superset / superset-ui / packages / superset-ui-chart / src / registries / ChartComponentRegistrySingleton.ts View on Github external
import { Registry, makeSingleton, OverwritePolicy } from '@superset-ui/core';
import { ChartType } from '../models/ChartPlugin';

class ChartComponentRegistry extends Registry {
  constructor() {
    super({ name: 'ChartComponent', overwritePolicy: OverwritePolicy.WARN });
  }
}

const getInstance = makeSingleton(ChartComponentRegistry);

export default getInstance;
github apache-superset / superset-ui / packages / superset-ui-number-format / src / NumberFormatterRegistrySingleton.ts View on Github external
import { makeSingleton } from '@superset-ui/core';
import NumberFormatterRegistry from './NumberFormatterRegistry';

const getInstance = makeSingleton(NumberFormatterRegistry);

export default getInstance;

export function getNumberFormatter(format: string) {
  return getInstance().get(format);
}

export function formatNumber(format: string, value: number | null | undefined) {
  return getInstance().format(format, value);
}
github apache-superset / superset-ui / packages / superset-ui-color / src / SequentialSchemeRegistrySingleton.ts View on Github external
import { makeSingleton } from '@superset-ui/core';
import ColorSchemeRegistry from './ColorSchemeRegistry';
import SequentialScheme from './SequentialScheme';
import schemes from './colorSchemes/sequential/d3';

class SequentialSchemeRegistry extends ColorSchemeRegistry {
  constructor() {
    super();

    this.registerValue('SUPERSET_DEFAULT', schemes[0]);
  }
}

const getInstance = makeSingleton(SequentialSchemeRegistry);

export default getInstance;
github apache-superset / superset-ui / packages / superset-ui-color / src / CategoricalSchemeRegistrySingleton.ts View on Github external
import { makeSingleton } from '@superset-ui/core';
import CategoricalScheme from './CategoricalScheme';
import ColorSchemeRegistry from './ColorSchemeRegistry';
import schemes from './colorSchemes/categorical/d3';

class CategoricalSchemeRegistry extends ColorSchemeRegistry {
  constructor() {
    super();

    this.registerValue('SUPERSET_DEFAULT', schemes[0]);
  }
}

const getInstance = makeSingleton(CategoricalSchemeRegistry);

export default getInstance;
github apache-superset / superset-ui / packages / superset-ui-time-format / src / TimeFormatterRegistrySingleton.ts View on Github external
import { makeSingleton } from '@superset-ui/core';
import TimeFormatterRegistry from './TimeFormatterRegistry';

const getInstance = makeSingleton(TimeFormatterRegistry);

export default getInstance;

export function getTimeFormatter(formatId: string) {
  return getInstance().get(formatId);
}

export function formatTime(formatId: string, value: Date | null | undefined) {
  return getInstance().format(formatId, value);
}