config#IS_DEV TypeScript Examples

The following examples show how to use config#IS_DEV. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: store.ts    From lightning-terminal with MIT License 6 votes vote down vote up
createStore = (grpcClient?: GrpcClient, appStorage?: AppStorage) => {
  const grpc = grpcClient || new GrpcClient();
  // Resolve api requests with sample data when running client in develop mode.
  grpc.useSampleData = USE_SAMPLE_DATA;

  const storage = appStorage || new AppStorage();
  const lndApi = new LndApi(grpc);
  const loopApi = new LoopApi(grpc);
  const poolApi = new PoolApi(grpc);
  const litApi = new LitApi(grpc);
  const csv = new CsvExporter();
  const history = createBrowserHistory();

  const store = new Store(
    lndApi,
    loopApi,
    poolApi,
    litApi,
    storage,
    history,
    csv,
    actionLog,
  );

  // initialize the store immediately to fetch API data, except when running unit tests
  if (!IS_TEST) store.init();

  // in dev env, make the store accessible via the browser DevTools console
  if (IS_DEV) (global as any).store = store;

  return store;
}
Example #2
Source File: batchStore.ts    From lightning-terminal with MIT License 6 votes vote down vote up
startPolling() {
    if (IS_TEST) return;
    if (this._pollingInterval) this.stopPolling();
    this._store.log.info('start polling for Pool data');
    // create timer to poll for new Pool data every minute
    this._pollingInterval = setInterval(async () => {
      this._store.log.info('polling for latest Pool data');
      await this.fetchLatestBatch();
      await this._store.accountStore.fetchAccounts();
      await this._store.orderStore.fetchOrders();
    }, (IS_DEV ? 15 : 60) * 1000);
  }
Example #3
Source File: log.ts    From lightning-terminal with MIT License 6 votes vote down vote up
/**
   * creates a new Logger instance by inspecting the executing environment
   */
  static fromEnv(namespace: string): Logger {
    // by default, log everything in development and nothing in production
    let level = IS_DEV ? LogLevel.debug : LogLevel.none;

    if (localStorage.getItem('debug')) {
      // if a 'debug' key is found in localStorage, use the level in storage or 'debug' by default
      const storageLevel = localStorage.getItem('debug-level') || 'debug';
      level = LogLevel[storageLevel as keyof typeof LogLevel];
    } else if (IS_DEV) {
      // if running in development with no localStorage key, use debug
      level = LogLevel.debug;
      // set the keys so they can be easily changed in the browser DevTools
      localStorage.setItem('debug', '*');
      localStorage.setItem('debug-level', 'debug');
    }

    return new Logger(level, namespace);
  }