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

fix: Allow events without parameters #792

Merged
merged 1 commit into from
Jul 17, 2024
Merged

fix: Allow events without parameters #792

merged 1 commit into from
Jul 17, 2024

Conversation

susnux
Copy link
Contributor

@susnux susnux commented Jun 24, 2024

Currently emit requires two parameters even if the event type is set to undefined. So emit('foo') will cause a Typescript error.

This fixes it by removing the second argument if the event type is set to undefined.


common:

declare module '@nextcloud/event-bus' {
	export interface NextcloudEvents {
		// mapping of 'event name' => 'event type'
		'my:event': undefined
	}
}

before:

emit('my:event', undefined)

after

emit('my:event')

@susnux susnux added bug Something isn't working 3. to review labels Jun 24, 2024
Currently `emit` requires two parameters even if the event type is set to `undefined`.
So `emit('foo')` will cause a Typescript error.

This fixes it by removing the second argument if the event type is set to undefined.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
@susnux susnux merged commit f01f4c9 into main Jul 17, 2024
16 checks passed
@susnux susnux deleted the fix/allow-void-events branch July 17, 2024 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants