Get the instance of Svrx
Usage
const svrx = require('@svrx/svrx');
const server = svrx({
port: 8002
});
Param
Return
the instance of Svrx
Start svrx
Usage
server.start().then(port => {
console.log(port);
});
Return
Promise
Usage
server.close().then(() => {
console.log('Svrx has closed');
});
Param
Return
Promise
Manually refresh the browser
Usage
server.reload();
Attach event listener
ready
Emit when svrx start
server.on('ready', port => {});
plugin
Emit after plugin building, as same as hook.onCreate
, see How to create plugin for more details
server.on('plugin', async ({io, events, config, router, injector, logger, middleware }=>{
// you logic here
}))
file:change
emit after file change (make sure that livereload is enable)
unbind specific event
server.on('file:change', handler);
server.off('file:change', handler);
server.emit('custom-event', { param1: 1 });