Add pre-change notifications to sources
- Dominant language
- Python
- Stars
- 5.4k
- Forks
- 827
- Avg merge
- 9h 45m
- Merged PRs (30d)
- 58
Description
### What is the problem or limitation you are having?
At present, change notifications on a source are all "post change" - the notification is sent after the change has taken effect.
#4202 has highlighted that there is a need for "pre-change" notifications as well so that representations can accommodate changes *before* the change occurs. There are also opportunities to optimize other widgets on other platforms (e.g., DetailedList on macOS) if pre_notifications are available.
### Describe the solution you'd like
Every notification that is generated by a Source (ListSource, TreeSource or ValueSource) should have a corresponding "pre_" analog - so:
* `pre_insert` is issued just before an insertion occurs
* `pre_change` is issued just before a change occurs
* `pre_delete` is issued just before a deletion occurs
* `pre_clear` is issued just before a deletion occurs.
These "pre" notification should be given the same context as their corresponding "post" notifications (e.g. `index` and `item` for a `pre_delete` notification).
The existence of these new notifications should *not* require any additional changes to existing code. An existing listener *can* implement a `pre_*` notification handler, but is not *required* to implement that handler.
### Describe alternatives you've considered
Status quo - continue to only have post-notifications, and accommodate them.
### Additional context
_No response_
Contributor guide
Research direction
Start by locating the ListSource, TreeSource, and ValueSource implementations and tracing their existing post-change notification paths. Check how context such as index and item is passed to listeners. Done means each post notification has a corresponding pre_ notification with equivalent context, while existing listeners continue to work unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100