@microsoft/windows-admin-center-sdk
Version:
Microsoft - Windows Admin Center Shell
1 lines • 1.34 kB
Source Map (JSON)
{"version":3,"sources":["../../../packages/core/base/decorators/delay.decorator.ts"],"names":[],"mappings":"AAOA,wBAAgB,KAAK,CAAC,KAAK,GAAE,MAAY,GAAG,eAAe,CAkB1D","file":"delay.decorator.d.ts","sourcesContent":["/*\r\n * @Delay() Method Decorator\r\n * delay a methods execution to the end of the event loop.\r\n * Note: this only works with functions that return void. The delay makes it impossible to return values in the\r\n * same context as the function was originally executed.\r\n * @returns A @see MethodDecorator for the method that this is decorating\r\n */\r\nexport function Delay(delay: number = 200): MethodDecorator {\r\n // eslint-disable-next-line unused-imports/no-unused-vars\r\n return <T>(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\r\n // copy the descriptor\r\n const method = { ...descriptor };\r\n // remember the old value\r\n const value = method.value;\r\n // create a new value that yields using set timeout\r\n method.value = function (...args) {\r\n const instance = this;\r\n // requeue the real method on the end of the event loop.\r\n setTimeout(() => {\r\n value.apply(instance, args);\r\n }, delay);\r\n };\r\n\r\n return method;\r\n };\r\n}\r\n"]}