Skip to content

Very easy-to-make error with event dispatcher's .trigger function. #1307

@bogdan-brz

Description

@bogdan-brz

I was just struggling with a weird logical error where my event handler simply wouldn't be called by the .trigger function of the dispatcher.
Finally, I figured out my error:

struct SomeEvent
{
};
entt::dispatcher dispatcher;
// connected some handler...
dispatcher.trigger<SomeEvent>({});

That's it...
The error is the curly braces. The function works properly if you either give it full 'SomeEvent{}' or nothing at all... Somehow the curly braces evaluate to a wrong type hash.

@skypjack - The docs already give the correct two ways to use the function, but this does compile and is hard to spot - maybe the docs should mention this as something NOT to do?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions