diff --git a/packages/arch/src/use-case/use-case.ts b/packages/arch/src/use-case/use-case.ts index 3baee07..979530b 100644 --- a/packages/arch/src/use-case/use-case.ts +++ b/packages/arch/src/use-case/use-case.ts @@ -1,3 +1,5 @@ +import { CacheKey } from '../cache/cache-key' +import { USE_CASE_KEY } from '../cache/use-case-key' import { Runner } from '../runner/runner' import { ExecutionOptions } from './execution-options' @@ -10,6 +12,12 @@ export abstract class UseCase { private static currentId = 0 private subscriptions = new Map>() + get key(): CacheKey { + return ( + this.constructor.prototype?.[USE_CASE_KEY] ?? this.constructor.prototype?.[USE_CASE_KEY] ?? this.constructor.name + ) + } + subscribe(fn: Fn): Id { const id = UseCase.currentId++ this.subscriptions.set(id, fn)