Created
August 28, 2020 13:42
-
-
Save ziuniecki/e10dc1d03f80c3d8741421d3c12d2dc3 to your computer and use it in GitHub Desktop.
Function decorator with params
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Observable } from 'rxjs'; | |
export const ExampleDecorator: () => MethodDecorator = () => (target: unknown, propertyKey: string, descriptor: PropertyDescriptor) => { | |
const original: () => Observable<unknown> = descriptor.value; | |
descriptor.value = function(): Observable<unknown> { | |
try { | |
return original.apply(this, arguments).pipe(); | |
} catch { | |
return original.apply(this, arguments); | |
} | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment