简体   繁体   English

我不理解Flux中Dispatcher.js中的某些语法

[英]I don't understand some syntax in Dispatcher.js in Flux

While reading code on Flux, I found some lines I don't understand. 在Flux上阅读代码时,我发现了一些我不理解的行。

Source: https://github.com/facebook/flux/blob/master/src/Dispatcher.js 来源: https : //github.com/facebook/flux/blob/master/src/Dispatcher.js

  1. On line 109, the angle brackets 在第109行,尖括号

     class Dispatcher<TPayload> 
  2. On line 110-115, the whole block doesn't look like javascript. 在第110-115行,整个块看起来都不像javascript。

     _callbacks: {[key: DispatchToken]: (payload: TPayload) => void}; _isDispatching: boolean; _isHandled: {[key: DispatchToken]: boolean}; _isPending: {[key: DispatchToken]: boolean}; _lastID: number; _pendingPayload: TPayload; 
  3. On line 138, the function with : void before curly braces. 在第138行,花括号前带有: void的函数。

     unregister(id: DispatchToken): void { ...} 

I thing it is because of some kind of js library. 我的东西是因为某种js库。 But I'm not sure. 但是我不确定。 The only trace I can find is that invariant is required for this js file. 我只能找到的唯一跟踪是此js文件需要不变。 but I can't find the code or documents of invariant. 但我找不到不变式的代码或文件。

It isn't just Javascript (check out this line ), it's flow . 只是 Javascript(请查看此行 ),它是流程

Flow adds static type checking to Javascript code. Flow向Javascript代码添加了静态类型检查。

Specifically: 特别:

  1. http://flowtype.org/docs/classes.html#polymorphic-classes http://flowtype.org/docs/classes.html#polymorphic-classes
  2. It's a mix of es6 and Flow syntax 混合使用es6和Flow语法
  3. http://flowtype.org/docs/functions.html#type-annotating-functions http://flowtype.org/docs/functions.html#type-annotating-functions

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM