UNPKG

scrivito

Version:

Scrivito is a professional, yet easy to use SaaS Enterprise Content Management Service, built for digital agencies and medium to large businesses. It is completely maintenance-free, cost-effective, and has unprecedented performance and security.

20 lines (15 loc) 416 B
export class ContextContainer<ContextType> { private currentContext: ContextType | undefined; current(): ContextType | undefined { return this.currentContext; } runWith<T>(valueForFunction: ContextType, fn: () => T): T { const before = this.currentContext; try { this.currentContext = valueForFunction; return fn(); } finally { this.currentContext = before; } } }