Skip to content

fix: Allow events without parameters#792

Merged
susnux merged 1 commit intomainfrom
fix/allow-void-events
Jul 17, 2024
Merged

fix: Allow events without parameters#792
susnux merged 1 commit intomainfrom
fix/allow-void-events

Conversation

@susnux
Copy link
Copy Markdown
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
@susnux susnux force-pushed the fix/allow-void-events branch from 8e305ae to 6bf0e21 Compare June 24, 2024 13:23
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 force-pushed the fix/allow-void-events branch from 6bf0e21 to b55f4c6 Compare June 24, 2024 14:43
@susnux susnux merged commit f01f4c9 into main Jul 17, 2024
@susnux susnux deleted the fix/allow-void-events branch July 17, 2024 13:13
@susnux susnux mentioned this pull request Feb 28, 2025
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