How do you write this in JavaScript?

Asked 1 years ago, Updated 1 years ago, 56 views

I was looking at Flux's Dispatcher.js source.

class Dispatcher <TPayload > {
  _callbacks:{[key:DispatchToken]:(payload:TPayload)=>void};

<TPayload> and _callbacks:{[key:DispatchToken]:(payload:TPayload)=>void};

in the .

In addition to the above,

register(callback:(payload:TPayload)=>void): DispatchToken{

I saw a way of writing like this, but what kind of notation is this?

javascript redux

2022-09-30 18:40

1 Answers

The Dispatcher.js says @flow, so it is JS type annotated by flow

.

The <TPayload> part defines the Dispatcher class with parameters and names the parameter TPayload ( class ).

_callbacks:{[key:DispatchToken]:(payload:TPayload)=>void} declares the _callbacks member type as key-value


2022-09-30 18:40

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.