-
Notifications
You must be signed in to change notification settings - Fork 4
Middlewares
Eric M. Dantas edited this page May 16, 2018
·
2 revisions
// npm i --save-dev aliv
const Server = require('aliv')
const aliv = new Server()
aliv.use((done) => {
console.log("hey, I'm a sync middleware :)")
console.log("I run right before a browser reload is about to happen")
done()
})
aliv.use((done) => {
setTimeout(() => {
console.log("And I'm an async middleware :D")
console.log("I too run right before a browser reload is about to happen")
done()
}, 1000)
})
aliv.start()
The key point to notice is the done()
function. It has to be called so aliv
knows when to call the next middleware.
And, yes, the order defined is the same execution order before the browser reload is called.