Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839
  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. begin(session: BaseSession) {
  17. this._current = session
  18. return this
  19. }
  20. complete<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. }
  29. const session = new SessionManager()
  30. export default session