zundo icon indicating copy to clipboard operation
zundo copied to clipboard

Proposal: Return function instead of undefined.

Open nosferatu500 opened this issue 3 years ago • 5 comments

Now if I trying to call zundo funcs (undo/redo/clear) when undo / redo history is empty, zundo will return undefined instead of undo, redo, clear funcs.

I have 6 different stores and now I have to wrap each call with if (get().undo) get().undo() for each zundo funcs. It's not an issue but looks a little dirty. What if zundo would return a function regardless of the content of the history?

nosferatu500 avatar Jul 12 '21 10:07 nosferatu500

That's a good catch. Would you be able to post a code snippet so I can be certain I understand the context?

Thanks.

charkour avatar Jul 12 '21 16:07 charkour

I'll do it later today.

nosferatu500 avatar Jul 13 '21 00:07 nosferatu500

Sounds good. Thanks!

charkour avatar Jul 13 '21 00:07 charkour

Hey! Sorry for the delay, but I'm too busy this week.

I will show an example with a bug this weekend.

nosferatu500 avatar Jul 14 '21 01:07 nosferatu500

Sounds good. I'm busy as well so this weekend will be great. Thanks!

charkour avatar Jul 14 '21 02:07 charkour

This is no longer an issue in v2. Thanks for the great suggestion!

charkour avatar Apr 22 '23 22:04 charkour