Skip to content

Keep attached events#85

Merged
da-h merged 2 commits intomasterfrom
keep_attached_events
Nov 10, 2021
Merged

Keep attached events#85
da-h merged 2 commits intomasterfrom
keep_attached_events

Conversation

@da-h
Copy link
Copy Markdown
Owner

@da-h da-h commented Nov 10, 2021

Keep attached events on overwriting

Attention: This is a breaking change.

This MR changes the way events are overwritten/redefined using mf.unregister_event or mf.overwrite_event.

Description

By default, a call to any of the mentioned methods, all events of the given name are unregistered from miniflask (either only their function cache or any of their future uses), and also all events that are attached to the event to be changed.

A typical used-case, however is the transformation of events using other modules using before_ and after_ event hooks (attached events). With other words, replacing an event should not replace the hooks used to modify or inspect the calls when changing its function.

This MR thus, by default, keeps all attached events upon reregistration, but allows the user to remove all additional (typically) user-events as well.

Things done in this MR

  • added keep_attached_events to mf.unregister_event and mf.overwrite_event

Check all before creating this PR:

  • Documentation adapted
  • unit tests adapted / created

@da-h da-h requested a review from sbrodehl November 10, 2021 16:53
@da-h da-h merged commit e6faedc into master Nov 10, 2021
@da-h da-h deleted the keep_attached_events branch November 11, 2021 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants