Skip to content

Instantly share code, notes, and snippets.

@ziuniecki
Created August 28, 2020 13:42
Show Gist options
  • Save ziuniecki/e10dc1d03f80c3d8741421d3c12d2dc3 to your computer and use it in GitHub Desktop.
Save ziuniecki/e10dc1d03f80c3d8741421d3c12d2dc3 to your computer and use it in GitHub Desktop.
Function decorator with params
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