Skip to content

Enhancement: Improve event handler registration and unregistration #29

Description

@YexuanXiao

Follow up #23. Currently, C++/WinRT requires three overloads of the member function named Event for registering and unregistering event handlers:

winrt::event_token Event(EventHandler);
Class::Event_revoker Event(winrt::auto_revoker_t, EventHandler);
void Event(winrt::event_token);

When the option -ms-extension-property is enabled, a type winrt::auto_revoker_type_t should be added, and the member __declspec(property(get = _get_Event_register)) T Event; should be defined, where T holds a reference to the current object, and T defines

winrt::event_token operator+=(EventHandler);
Class::Event_revoker operator+=(winrt::auto_revoker_type_t<EventHandler>);
void operator-=(winrt::event_token)

and winrt::auto_revoker_t is no longer needed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationfeatureNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions