Front end of the Slack clone application.

123456789101112131415161718192021222324252627282930
  1. // API
  2. module.exports = abort;
  3. /**
  4. * Aborts leftover active jobs
  5. *
  6. * @param {object} state - current state object
  7. */
  8. function abort(state)
  9. {
  10. Object.keys(state.jobs).forEach(clean.bind(state));
  11. // reset leftover jobs
  12. state.jobs = {};
  13. }
  14. /**
  15. * Cleans up leftover job by invoking abort function for the provided job id
  16. *
  17. * @this state
  18. * @param {string|number} key - job id to abort
  19. */
  20. function clean(key)
  21. {
  22. if (typeof this.jobs[key] == 'function')
  23. {
  24. this.jobs[key]();
  25. }
  26. }