Skip to content

Improve hooks api #50

@TimoBechtel

Description

@TimoBechtel

Currently, if one wants to hook into a lifecylce function, e.g. server:update, one needs to pass a plugin object to the SocketDB initializing function.

SocketDBServer({
	plugins: [{
		name: 'my-plugin',
		hooks: {
			'server:update': () => {
				console.log('update')
			}
		}
	}]
})

This could be made easier to use by adding a intercept function:

server.intercept('server:update', () => {
	console.log('update');
});

Or on, but this might be misleading, as you might get the impression of this being a websocket event

server.on('server:update', () => {
	console.log('update');
});

It does the same thing, but just makes it a bit easier to use.

Metadata

Metadata

Assignees

No one assigned

    Labels

    idearough idea for a new feature

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions