[Help] How do I made `zundo` work with `subscribeWithSelector` in typescript?
How do I made zundo work with subscribeWithSelector in typescript?
Wrapping subscribeWithSelector with zundo middleware unleashes Pandora's box and it does not make sense to me, a relatively new typescipt-er.
I have tried extending BlueprintStoreState with zundo's UndoState (reference: https://github.com/charkour/zundo#alternatively-use-the-middleware), but that got me nowhere).
Current code:
interface BlueprintStoreState extends Blueprint {}
const blueprintStore = create<
BlueprintStoreState,
SetState<BlueprintStoreState>,
GetState<BlueprintStoreState>,
Mutate<
StoreApi<BlueprintStoreState>,
[['zustand/subscribeWithSelector', never]]
>
>(
subscribeWithSelector(() => blueprintTemplate),
);
Hey! Thanks for making this issue.
To be honest, I haven't tried using zundo with SubscribeWithSelector. Would you be willing to provide a code sandbox with the issue you are seeing? That will help me debug the issue more quickly. Thanks!
Wow, I made it work in the sandbox somehow; I surprise myself sometimes...
https://codesandbox.io/s/angry-star-njtw0r
Edit: I haven't tested it yet, so I am going to keep this issue open. If I find no issues, I'll close it.
Awesome, thanks for the update. Check back and let me know how it goes. Thanks!
I updated the sandbox to actually test the selector, and it is working flawlessly!
Edit: feel free to put this in the docs as an example.
Thanks!! I'll update the docs tonight. Thanks for the example and for the updates!
Re-opening so I update the docs.