Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { AsyncAction } from './AsyncAction';
  2. import { AsyncScheduler } from './AsyncScheduler';
  3. /**
  4. *
  5. * Async Scheduler
  6. *
  7. * <span class="informal">Schedule task as if you used setTimeout(task, duration)</span>
  8. *
  9. * `async` scheduler schedules tasks asynchronously, by putting them on the JavaScript
  10. * event loop queue. It is best used to delay tasks in time or to schedule tasks repeating
  11. * in intervals.
  12. *
  13. * If you just want to "defer" task, that is to perform it right after currently
  14. * executing synchronous code ends (commonly achieved by `setTimeout(deferredTask, 0)`),
  15. * better choice will be the {@link asapScheduler} scheduler.
  16. *
  17. * ## Examples
  18. * Use async scheduler to delay task
  19. * ```ts
  20. * import { asyncScheduler } from 'rxjs';
  21. *
  22. * const task = () => console.log('it works!');
  23. *
  24. * asyncScheduler.schedule(task, 2000);
  25. *
  26. * // After 2 seconds logs:
  27. * // "it works!"
  28. * ```
  29. *
  30. * Use async scheduler to repeat task in intervals
  31. * ```ts
  32. * import { asyncScheduler } from 'rxjs';
  33. *
  34. * function task(state) {
  35. * console.log(state);
  36. * this.schedule(state + 1, 1000); // `this` references currently executing Action,
  37. * // which we reschedule with new state and delay
  38. * }
  39. *
  40. * asyncScheduler.schedule(task, 3000, 0);
  41. *
  42. * // Logs:
  43. * // 0 after 3s
  44. * // 1 after 4s
  45. * // 2 after 5s
  46. * // 3 after 6s
  47. * ```
  48. */
  49. export const asyncScheduler = new AsyncScheduler(AsyncAction);
  50. /**
  51. * @deprecated renamed. Use {@link asyncScheduler}
  52. */
  53. export const async = asyncScheduler;