K
K
Konstantin2020-01-17 16:00:55
JavaScript
Konstantin, 2020-01-17 16:00:55

What is a promise entry?

What is this promise entry form - how does it work?

layerSearchActions: { [layer: number]: (items: LayerItemGeneric[], search: string) => Promise<{ [key: string]: LayerWellTool }>;} = {
    335: async (
      items: LayerItemGeneric[],
      search: string
    ): Promise<{ [key: string]: LayerWellTool }> => {

 }
  };

Can explain step by step, for the first time I meet such a record

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alex, 2020-01-17
@Junart1

A promise that resolves to an object, with type keys stringand valuesLayerWellTool

const foo: Promise< тут указывается тип данных которые возвращаются из промиса >

V
Vitaly, 2020-01-17
@vshvydky

{ [layer: number]: (items: LayerItemGeneric[], search: string) => Promise<{ [key: string]: LayerWellTool }>;}

it is written here that the object of such an interface contains properties of the number type, the value of which is a function with parameters that returns a promise,
the fields are respectively items, this is an array of elements of the LayerItemGeneric type and a certain search string,
the return value of the promise is used as a generic, it is shown that the returned the result will be some object whose properties will be some strings whose value will (each) be something of type LayerWellTool

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question