-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
fix(query-core): convert notifyManager from factory function to class #7935
Conversation
fc5b2de
to
47181a1
Compare
☁️ Nx Cloud ReportCI is running/has finished running commands for commit bc88bf4. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution
✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
More templates
@tanstack/eslint-plugin-query
@tanstack/angular-query-experimental
@tanstack/query-async-storage-persister
@tanstack/query-broadcast-client-experimental
@tanstack/query-core
@tanstack/query-devtools
@tanstack/query-persist-client-core
@tanstack/query-sync-storage-persister
@tanstack/react-query
@tanstack/react-query-devtools
@tanstack/react-query-next-experimental
@tanstack/react-query-persist-client
@tanstack/solid-query
@tanstack/solid-query-devtools
@tanstack/solid-query-persist-client
@tanstack/svelte-query
@tanstack/svelte-query-devtools
@tanstack/svelte-query-persist-client
@tanstack/vue-query
@tanstack/vue-query-devtools
@tanstack/angular-query-devtools-experimental
commit: |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7935 +/- ##
===========================================
+ Coverage 44.51% 61.85% +17.33%
===========================================
Files 195 134 -61
Lines 7279 4679 -2600
Branches 1629 1304 -325
===========================================
- Hits 3240 2894 -346
+ Misses 3662 1543 -2119
+ Partials 377 242 -135 |
I remember moving this to a function because it was significantly smaller in bundle size. Can you check the size differences please? |
Okay, I'll check |
Size differencesI don't think it will increase significantly. We can expect library users to minify notifyManager through their bundlers for each service, and if so, we can expect the difference to be even smaller. AS IS: factory functionTO BE: class with jsdocmodern: 773,829 bytes -> 775,039 bytes (+1210 bytes) JSDoc differences (What I want to focus)But In my opinion, the biggest difference, other than the size, is that jsdoc in notifyManager is not included when it is a factory function (To include jsdoc, we should attatch jsdoc on return position function createNotifyManager(){
/**
* this jsdoc will be removed on notifyManager when build time
*/
const batch = <T>(callback: () => T): T => {
// ...
}
// ...
return {
/**
* jsdoc should be on this position, not function definition position
*/
batch,
batchCalls,
schedule,
setNotifyFunction,
setBatchNotifyFunction,
setScheduler,
} as const
} ). notifyManager is a public API of @tanstack/query-core and I thought it would be a more useful choice to keep the jsdoc where each method is used rather than having it disappear. AS IS: factory function (jsdoc of methods will be disappeared)setBatchNotifyFunction or other methods' jsdoc will be removed TO BE: class (jsdoc of methods will be restored)setBatchNotifyFunction or other methods' jsdoc will be restored TO BE: class without jsdocmodern: 773,829 bytes -> 772,227 bytes (-1602 bytes) @TkDodo I'm curious about your opinion on this. |
I think we can rather move the jsdoc, or even inline the functions into the return statement:
we also don't really have any meaningful jsdocs here. |
It's not must, but FocusManager, OnlineManager is class. so I thought that NotifyManager should be class consistently