Comments (5)
嗯,我認為可行。
回傳一個 Promise
表示監聽器需要時間思考如何響應,其中如果實現了 string
值表示它想到要響應什麼訊息了;反之,實現值為 void
表示反悔了,不響應了。
👍
這些行為目前的代碼已經支持,就差文檔與 ts 聲明文件的修正。
from node-cq-websocket.
或者,若要更精確的描述目前的行為,其 ts 聲明應如下。
因為不光是 void
,只要實現值不為 string
全部都表示不響應了。
type NonString = Exclude<any, string>
type MessageEventListener = (event: CQEvent, context: Record<string, any>) => string | NonString | Promise <string>| Promise<NonString>
from node-cq-websocket.
type NonString = Exclude<any, string>
string | NonString === any
from node-cq-websocket.
NonString
確實除了 void
以外的值都沒什麼意思, 為了不誤導用戶, 就以 string | void | Promise <void> | Promise <string>
。
from node-cq-websocket.
已更新 ts 聲明。 #27
from node-cq-websocket.
Related Issues (20)
- A list of deprecated APIs for v2 HOT 2
- Refactor the document
- Add the auto-build of CQWebSocket browser version into CI pipeline HOT 1
- HelpWanted HOT 3
- Inconsistent parameters among message events HOT 1
- Support meta events
- Wrong version used for browser bundle, the previous version is used HOT 4
- Support Vue.js as a Vue plugin HOT 2
- WS connect problem HOT 1
- 怎么使用 HOT 6
- ES6 import failed HOT 4
- The test for manual re-connection failed frequently.
- Memory leak in EventBus HOT 2
- Development flows
- websocket can't be reconnected sometimes HOT 6
- d.ts文件声明中少了元事件的类型
- 想问问如何付费? HOT 2
- demo code not work HOT 2
- 如何发送群组消息?
- 缺失notice.group_ban事件 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-cq-websocket.