-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Refactor decorator wrapping logic #27
Conversation
WhiteKiwi
commented
Nov 4, 2023
- Cache Key Strategy Change: Shifted cache key from method name to metadata.
- Decorator Logic Refactoring.
- Dependencies Update: Upgraded to TypeScript 5.0 and updated other dependencies to their latest versions.
const { originalFn, metadata, aopSymbol } = aopMetadata; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-this-alias | ||
const self = this; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
후우움
src/auto-aspect-executor.ts
Outdated
|
||
// eslint-disable-next-line @typescript-eslint/no-this-alias | ||
const self = this; | ||
function wrappedFunction(this: object, ...args: unknown[]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이름이 왜 wrappedFunction 이에용?
오히려 wrap 이렇게 하는게 낫지않나 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아 구두 논의 완료.
Function이라는 키워드가 생각보다 직관적이지 않은것 같기도 해서 고민이네요.
src/auto-aspect-executor.ts
Outdated
} | ||
|
||
target[aopSymbol] ??= {}; | ||
target[aopSymbol][methodName] = wrappedFunction; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't use Proxy, name of the method will be wrappedFunction
and it affects stack and make it hard to debug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/auto-aspect-executor.ts
Outdated
}) { | ||
const { originalFn, metadata, aopSymbol } = aopMetadata; | ||
|
||
const proxy = new Proxy(originalFn, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
프록시를 사용하려고 했던 이유에 대한 테스트 작성 가능하실까요?
프록시를 뺐다가, 다시 넣은 이유에 대해서 확인이 필요해보여요.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function that we tried to protect using Proxy, we already have code to protect in "createDecoder". And there are related tests.
c2a2ad0
to
50a1733
Compare