Skip to content

Instantly share code, notes, and snippets.

@msarsha
Created February 22, 2018 21:27
Show Gist options
  • Save msarsha/f8a7f9840e38abf7aaa1d11c1e2dada0 to your computer and use it in GitHub Desktop.
Save msarsha/f8a7f9840e38abf7aaa1d11c1e2dada0 to your computer and use it in GitHub Desktop.
@Injectable()
export class NastyService {
constructor(@Inject(CASE_LOGIC_HANDLER) private caseHandlers: CaseLogicHandler[]) {
}
doNastyOperation(key: any) {
const handler = this.caseHandlers.find(h => h.key === key);
if (!handler) throw new Error(`No case handler provided for key: ${key}`);
handler.doLogic();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment