K
K
Konstantin2021-02-10 16:15:51
Angular
Konstantin, 2021-02-10 16:15:51

How not to mutate the original data?

There is a method that makes a request to the server and returns data of the type: RegistryGenericwith a preliminary conversion to<Map<number, RegistryGeneric>>

interface RegistryGeneric {
   id: number;
   name: number;
}


Further in the template, `>` is displayed. Pokulik on one of them - it's easy to load geodata and put it inside.

I do not want to mutate the original object and add a field to the interface, because this field is not on the server.

interface RegistryGeneric {
   id: number;
   name: number;
   geodata: Geo[]
}


You can create an extended interface and inherit from the original one:

interface RegistryGenericUI extends RegistryGeneric {
   geodata: Geo[]
}


And use this interface in all UI views and components.

How to do it correctly and add uploadable data?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
t800zippygod, 2021-02-18
@Junart1

Well, creating a new legacy interface is a good solution IMHO

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question