小编Gre*_*gor的帖子

JavaScript事件命名约定

我们刚刚讨论了使用现在或过去的表单来表示事件名称.事实是,事件通常在发生事件后触发:

store.save(object)
store.trigger("create", object)
Run Code Online (Sandbox Code Playgroud)

我想知道是否有任何事件命名约定?使用过去的形式更有意义,另一方面,我的印象是使用现有的形式被更广泛地使用.

这个问题有什么好的资源吗?您是否知道使用过去表单的已知JavaScript库的事件?

javascript events naming-conventions

29
推荐指数
1
解决办法
5441
查看次数

链接静态.plugin()类方法以多次扩展实例API

我有一个插件架构,我可以执行此操作

const fooPlugin = () => ({ foo: 'foo' })
const barPlugin = () => ({ bar: 'bar' })

const BaseWithPlugin = Base.plugin(fooPlugin)
const baseWithPlugin = new BaseWithPlugin()
baseWithPlugin.foo // ? string

const BaseWithPlugins = Base.plugin([fooPlugin, barPlugin])
const baseWithPlugins = new BaseWithPlugins()
baseWithPlugins.foo // ? string
baseWithPlugins.bar // ? string
Run Code Online (Sandbox Code Playgroud)

但是这样做失败了

const BaseWithPlugins2 = Base.plugin(fooPlugin).plugin(barPlugin)
const baseWithPlugins2 = new BaseWithPlugins2()
baseWithPlugins2.foo // ? Property 'foo' does not exist on type 'plugin<() => { bar: string; }>.BaseWithPlugins & { bar: string; …
Run Code Online (Sandbox Code Playgroud)

typescript

4
推荐指数
1
解决办法
76
查看次数

GitHub Probot:错误probot:签名与事件有效负载和机密不匹配

我正在尝试使用Probot Framework构建GitHub应用程序。

这是file的内容index.js

module.exports = (robot) => {
  robot.log('Yay, the app was loaded!');
  robot.on('*', async context => {
    robot.log('Some event occured!');
  });
}
Run Code Online (Sandbox Code Playgroud)

但是,当我运行此应用程序时,将其安装在存储库中后,我收到此错误:

03:38:34.831Z ERROR probot: signature does not match event payload and secret
  Error: signature does not match event payload and secret
      at verifyAndReceive (/mnt/e/GSoC/test/test/node_modules/@octokit/webhooks/middleware/verify-and-receive.js:9:19)
      at IncomingMessage.request.on (/mnt/e/GSoC/test/test/node_modules/@octokit/webhooks/middleware/middleware.js:53:5)
      at emitNone (events.js:106:13)
      at IncomingMessage.emit (events.js:208:7)
      at endReadableNT (_stream_readable.js:1064:12)
      at _combinedTickCallback (internal/process/next_tick.js:138:11)
      at process._tickDomainCallback (internal/process/next_tick.js:218:9)
Run Code Online (Sandbox Code Playgroud)

这个错误背后的问题是什么?我该如何解决这个问题?

github github-api probot

3
推荐指数
1
解决办法
798
查看次数