Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { BaseSession } from './sessions'
  2. class SessionManager {
  3. private _current?: BaseSession
  4. clear() {
  5. this._current = undefined
  6. return this
  7. }
  8. setCurrent(session: BaseSession) {
  9. this._current = session
  10. return this
  11. }
  12. update<T extends BaseSession>(...args: Parameters<T['update']>) {
  13. this._current.update.call(null, ...args)
  14. return this
  15. }
  16. start(session: BaseSession) {
  17. this._current = session
  18. return this
  19. }
  20. compplete<T extends BaseSession>(...args: Parameters<T['complete']>) {
  21. this._current.complete.call(null, ...args)
  22. return this
  23. }
  24. cancel<T extends BaseSession>(...args: Parameters<T['cancel']>) {
  25. this._current.cancel.call(null, ...args)
  26. return this
  27. }
  28. get current() {
  29. return this._current
  30. }
  31. }
  32. const session = new SessionManager()
  33. export default session