Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow any return type from listener functions #12509

Merged
merged 1 commit into from
Jul 13, 2021

Conversation

ahocevar
Copy link
Member

@ahocevar ahocevar commented Jul 12, 2021

Fixes #12508.

With the current event listener types, something like this would not pass the type checks:

map.once('rendercomplete', async () => {
  await somethingDone();
  doSomething();
});

This is because the listener function is expected to return a boolean value or void.

In practice, we don't really care about the return value. Returning false from a listener function is equivalent to calling stopPropagation() on the event, but any other return type works too.

This pull request changes the expected return type to any, so the above snippet will now pass type checks.

@ahocevar ahocevar merged commit 7edc016 into openlayers:main Jul 13, 2021
@ahocevar ahocevar deleted the listener-return-type branch July 13, 2021 06:18
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.

The use of async/await on events callbacks
2 participants