Git Product home page Git Product logo

Comments (5)

momocow avatar momocow commented on May 29, 2024

嗯,我認為可行。

回傳一個 Promise 表示監聽器需要時間思考如何響應,其中如果實現了 string 值表示它想到要響應什麼訊息了;反之,實現值為 void 表示反悔了,不響應了。
👍

這些行為目前的代碼已經支持,就差文檔與 ts 聲明文件的修正。

from node-cq-websocket.

momocow avatar momocow commented on May 29, 2024

或者,若要更精確的描述目前的行為,其 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.

spacemeowx2 avatar spacemeowx2 commented on May 29, 2024

@momocow

type NonString = Exclude<any, string>
string | NonString === any

from node-cq-websocket.

momocow avatar momocow commented on May 29, 2024

NonString 確實除了 void 以外的值都沒什麼意思, 為了不誤導用戶, 就以 string | void | Promise <void> | Promise <string>

from node-cq-websocket.

momocow avatar momocow commented on May 29, 2024

已更新 ts 聲明。 #27

from node-cq-websocket.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.