$50 if someone can help me use subscribeWithSelector with TypeScript in my app #619
Replies: 3 comments 8 replies
-
Sorry for the trouble. create(subscribeWithSelector<...>((set) => ...)) If it's successful, you need to change the subscribe call, swap selector and callback: local.subscribe(selector, callback) Related: #616 We should document it better.. |
Beta Was this translation helpful? Give feedback.
-
Thanks! This tip plus the link in the release notes to https://github.com/pmndrs/zustand/blob/feef4d4db713992849ddb6b612c72e2ff107681d/tests/middlewareTypes.test.tsx made me realize that this works:
It would be nice if only one parameter was needed, like before, and it could automatically figure out those other 3. But I'm guessing that might be impossible if multiple middlewares are used. In which case, this is good enough. You still might want to add something to the documentation about this, because even in that test file the types are all applied to Anyway, if you tell me how to send you $50 I'll gladly do it, cause you definitely deserve it for your work here and elsewhere! |
Beta Was this translation helpful? Give feedback.
-
create(subscribeWithSelector<...>((set) => ...)) works for me too. Thanks @dai-shi |
Beta Was this translation helpful? Give feedback.
-
https://github.com/zengm-games/zengm/blob/11cdf79f87c69d67214446f580c8120ba943fe99/src/ui/util/local.ts#L30-L194 is my only Zustand store.
https://github.com/zengm-games/zengm/blob/11cdf79f87c69d67214446f580c8120ba943fe99/src/ui/components/Controller.tsx#L279-L298 is the one place I subscribe to it.
I see the deprecation message, and I see the example in the README. It works for a simple store, but when I try to use it here I get a giant mess of TypeScript errors and after like an hour of trying to figure out a better solution than casting the whole thing to
any
, I have not succeeded.So can I pay someone here for their expertise?
I can pay by Paypal, Venmo, Zelle, a check in the mail, crypto.. whatever. I just would like to get rid of the deprecation warning without losing my nice TypeScript types :)
Beta Was this translation helpful? Give feedback.
All reactions