How to use the codesandbox-api.actions.notifications function in codesandbox-api

To help you get started, we’ve selected a few codesandbox-api 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 codesandbox / codesandbox-client / src / sandbox / npm / fetch-dependencies.new.js View on Github external
try {
      const manifest = await callApi(url, method); // eslint-disable-line no-await-in-loop

      return manifest;
    } catch (e) {
      const statusCode = e.response && e.response.status;

      setScreen({ type: 'loading', text: 'Bundling Dependencies...' });

      // 403 status code means the bundler is still bundling
      if (retries < RETRY_COUNT && statusCode === 403) {
        retries += 1;
        await delay(1000 * 2); // eslint-disable-line no-await-in-loop
      } else if (retries < RETRY_COUNT && statusCode === 500) {
        dispatch(
          actions.notifications.show(
            'It seems like all packagers are busy, retrying in 10 seconds...',
            'warning'
          )
        );

        await delay(1000 * 2); // eslint-disable-line no-await-in-loop
        retries += 1;
      } else {
        throw e;
      }
    }
  }
}
github codesandbox / codesandbox-client / packages / app / src / sandbox / npm / fetch-dependencies.ts View on Github external
npmDependencies: Dependencies,
  resolutions?: { [key: string]: string }
) {
  if (Object.keys(npmDependencies).length !== 0) {
    // New Packager flow

    try {
      const result = await getDependencies(npmDependencies);
      setScreen({ type: 'loading', text: 'Transpiling Modules...' });

      return result;
    } catch (e) {
      e.message = `Could not fetch dependencies, please try again in a couple seconds: ${
        e.message
      }`;
      dispatch(actions.notifications.show(e.message, 'error'));

      throw e;
    }
  }
  return false;
}
github codesandbox / codesandbox-client / src / sandbox / npm / fetch-dependencies.js View on Github external
async function requestPackager(url, method = 'GET') {
  let retries = 0;

  dispatch(actions.notifications.show('Bundling dependencies...'));
  // eslint-disable-next-line no-constant-condition
  while (true) {
    debug(`Trying to call packager for ${retries} time`);
    try {
      const manifest = await callApi(url, method); // eslint-disable-line no-await-in-loop

      return manifest;
    } catch (e) {
      const statusCode = e.response && e.response.status;

      setScreen({ type: 'loading', text: 'Bundling Dependencies...' });

      // 403 status code means the bundler is still bundling
      if (retries < RETRY_COUNT && statusCode === 403) {
        retries += 1;
        await delay(1000 * 2); // eslint-disable-line no-await-in-loop

codesandbox-api

[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier) [![Greenkeeper badge](https://badges.greenkeeper.io/alexjoverm/typescript-library-starter.svg)](https://greenkeeper.io/) [![Travi

MIT
Latest version published 3 years ago

Package Health Score

73 / 100
Full package analysis

Similar packages