Functions inside/outside proxy
: which idiom is better (and why)?
#1032
Answered
by
dai-shi
rodrigocfd
asked this question in
Q&A
-
Functions outside export const store = proxy({
count: 0,
});
export function inc(): void {
++store.count;
} ...or functions inside export const store = proxy({
count: 0,
inc: (): void => {
++store.count;
},
}); Which idiom is better (and why)? |
Beta Was this translation helpful? Give feedback.
Answered by
dai-shi
Jan 10, 2025
Replies: 2 comments
-
Alternatively, this works too: export const store = proxy({
count: 0,
inc() {
++this.count;
},
}); |
Beta Was this translation helpful? Give feedback.
0 replies
-
All of them are good, but only the first one is capable of code splitting, I suppose. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
rodrigocfd
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
All of them are good, but only the first one is capable of code splitting, I suppose.