Skip to content
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

feat: dryRedo on replay_bloc #3551

Open
bernaferrari opened this issue Sep 19, 2022 · 1 comment
Open

feat: dryRedo on replay_bloc #3551

bernaferrari opened this issue Sep 19, 2022 · 1 comment
Labels
enhancement candidate Candidate for enhancement but additional research is needed pkg:replay_bloc This issue is related to the replay_bloc package

Comments

@bernaferrari
Copy link
Contributor

bernaferrari commented Sep 19, 2022

I love bloc and cubit, but I'm fighting with a few limitations.

Imagine Cubit as the Navigation stack (back/forward button, etc).
I wish I could do this:

  • I am on screen A, move to screen B, go back to A. Move B to the trash. I can't "redo" to go to B because B is on the trash, so I would need to check like trash.contains(dryRedo()). I don't want to redo. I want to know if I can redo based on redo value without removing it from its stack.
  • Browser back-stack. You might want to see a preview of the previous/next page. Maybe even the full back history, in a list. The following image is not possible with cubit:

image

Possible Desired Solutions

  • Something like dryRedo() / dryUndo() (maybe a better name?), that gets the value, but doesn't remove from the history.
  • Making history and current index not private. So the user could do history.range(index, history.length) and get the forward redo history.
  • Make List<T> undoValues(int? limit) and List<T> redoValues(int? limit), so redoValues(1).first would do what I want.

The last one is slightly more verbose but seems better. I also like the second one. If it were public inside the bloc, at least, I would be able to fix myself. Maybe with tuples it could be (int, ?) getHistoryIndex.

@bernaferrari bernaferrari changed the title feat: dryRedo feat: dryRedo on replay_bloc Sep 19, 2022
@felangel felangel added enhancement candidate Candidate for enhancement but additional research is needed pkg:replay_bloc This issue is related to the replay_bloc package labels Sep 19, 2022
@CodeDoctorDE
Copy link

Hello,
I'm currently coding a note-taking app where this functionality will also be useful.
The range function could be implemented using the take function: https://api.dart.dev/stable/3.0.0/dart-core/Iterable/take.html.
But currently, emit doesn't know on which event it was called: https://github.com/felangel/bloc/blob/master/packages/replay_bloc/lib/src/replay_cubit.dart#L67
Without this information, you couldn't add an undo history of a column like Adding stroke or something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement candidate Candidate for enhancement but additional research is needed pkg:replay_bloc This issue is related to the replay_bloc package
Projects
None yet
Development

No branches or pull requests

3 participants