starter.js 731 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * @Author: Rindy
  3. * @Date: 2020-03-06 15:49:01
  4. * @LastEditors: Rindy
  5. * @LastEditTime: 2020-04-03 12:02:39
  6. * @Description: 启动器
  7. */
  8. class Detector {
  9. constructor() {
  10. this._resolve = null
  11. }
  12. register(callback) {
  13. this._promise = callback(this)
  14. }
  15. listener() {
  16. if (!this._promise) {
  17. return Promise.resolve()
  18. }
  19. return this._promise
  20. }
  21. valid() {
  22. this._resolve && this._resolve()
  23. }
  24. resolve(resolve) {
  25. this._resolve = resolve
  26. }
  27. }
  28. /**
  29. * 是否上线检测器
  30. */
  31. export const OnlineDetector = new Detector()
  32. /**
  33. * 登录检测器
  34. */
  35. export const LoginDetector = new Detector()
  36. /**
  37. * 场景是否生成检测器
  38. */
  39. export const ListDetector = new Detector()