Skip to content
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

Merged
merged 5 commits into from
Nov 6, 2023
Merged

Conversation

WhiteKiwi
Copy link
Member

  1. Cache Key Strategy Change: Shifted cache key from method name to metadata.
  2. Decorator Logic Refactoring.
  3. Dependencies Update: Upgraded to TypeScript 5.0 and updated other dependencies to their latest versions.

@WhiteKiwi WhiteKiwi self-assigned this Nov 4, 2023
sok125
sok125 previously approved these changes Nov 6, 2023
const { originalFn, metadata, aopSymbol } = aopMetadata;

// eslint-disable-next-line @typescript-eslint/no-this-alias
const self = this;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

후우움


// eslint-disable-next-line @typescript-eslint/no-this-alias
const self = this;
function wrappedFunction(this: object, ...args: unknown[]) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이름이 왜 wrappedFunction 이에용?
오히려 wrap 이렇게 하는게 낫지않나 ?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 구두 논의 완료.
Function이라는 키워드가 생각보다 직관적이지 않은것 같기도 해서 고민이네요.

}

target[aopSymbol] ??= {};
target[aopSymbol][methodName] = wrappedFunction;
Copy link

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}) {
const { originalFn, metadata, aopSymbol } = aopMetadata;

const proxy = new Proxy(originalFn, {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

프록시를 사용하려고 했던 이유에 대한 테스트 작성 가능하실까요?
프록시를 뺐다가, 다시 넣은 이유에 대해서 확인이 필요해보여요.

Copy link
Member Author

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.

@WhiteKiwi WhiteKiwi merged commit f319395 into v2.x Nov 6, 2023
1 check passed
@WhiteKiwi WhiteKiwi deleted the refactor/wrap branch November 6, 2023 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants