Support hot-reload for Wechaty events listeners
Created by: huan
The API might add the following new features:
1. addListener
wechaty.on('message', './message-listener')
If the second parameter is a string instead of a function, then we can use func = require('./message-listener')
as the listener function, monitor the file, and reload it if the file had been updated.
2. WechatyInstanceOptions
bot = Wechaty.instance({
listenerDirectory: './listenerDirectory/' // this is the directory which contains all listeners.
})
Wechaty will scan ./listenerDirectory/
for the files that the same name as the event, then require
it and add it as the listener.
See Also
- https://github.com/fastest963/require-reload
- http://blog.chatie.io/developer/2017/03/20/added-hot-reload-for-bots.html
- https://blogs.msdn.microsoft.com/typescript/2017/06/12/announcing-typescript-2-4-rc/
- https://www.youtube.com/watch?v=cGqfM6huJCs
- Getting the stack trace in a structured form
- Get v8 stack traces as an array of CallSite objects.
- A node module for enabling a module to determine its caller.
- [Design Spec] ESNext import()
- Hot module replacement for node.js
- Hot reload tool for node.js
CC @Gcaufy