Conversation
- Added a new `@EventMethod` Property Wrapper to enable in-line, automatically-registering Event-invoked Callback Methods on any class implementing `EventListening` (for automatic registration) - Any Class implementing `EventListening` can now invoke `registerListeners()` at the end of its `init` method (or anywhere post-init you wish to do so, anyway) to automatically register all `@EventMethod`-decorated Event Callbacks. - Added a version of `@EventMethod` specifically for use in `EventThread` types. You don't need to invoke `registerListeners()` for your `EventThread` types, because the base `init` will already do this for you. - `EventThread` now supports multiple Callbacks for the same `Eventable` type. Invoking `addEventCallback` will now return a `UUID` containing the unique `token` of each Callback. This can be used with `removeEventCallback` to unregister the Callback at any time.
We cannot unregister or modify an `@EventMethod` once it is registered... so the code to try this has been removed.
To reflect the removed (impossible) Unregister code committed previously.
UUID tokens for `EventListener.addListener` have been replaced by a new `EventListenerHandling` protocol describing the `EventListenerHandler` class. This can be used to call `.remove()` and unregister the `Listener`. References are `weak`, and perform `nil`-checks as appropriate, so calling `.remove()` against an `EventListenerHandler` for an `EventListenable` that has been garbage collected won't raise any errors.
Documentation for the `UUID` *token* has been superseded by the new `EventListenerHandling` solution.
I've implemented `EventCallbackContainer` in `EventThread` for internal Callback management. This matches the `EventListener` solution (which also has a bug fix now)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implemented a number of enhancements for Event Listeners and Callbacks