felangel / felangel/bloc

feat: dryRedo on replay_bloc

Open
#3,551 1 comment 2 reactions 0 assignees View on GitHub
enhancement candidate pkg:replay_bloc
Dominant language
Dart
Stars
12.5k
Forks
3.4k
PR merge metrics
No merged PRs in 30d

Description

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 undoValues(int? limit)` and `List 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`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.