0
I just want to find what this type <V> for EntityState<V> is.

I just put the above in as code so that the V part shows up...( and I have no freaking idea how to search for something that is enclosed in chevrons or wtf those things are called)

I've searched for everything I can think of. The ngrx docs use it in the documentation for https://v7.ngrx.io/guide/entity/interfaces and I found this tutorial that mentions it - https://medium.com/ngrx/introducing-ngrx-entity-598176456e15

... but I just can't figure out what is type <V>.

Here is the interface it is used in:

interface EntityState<V> {
  ids: string[] | number[];
  entities: { [id: string | id: number]: V };
}

This probably sounds retarded but HOW do I figure out the answer 
to this seemingly incredibly simple question?  What is <V>?
Leo Ku
  • 73
  • 2
  • 6

1 Answers1

0

So it is using typescript.

interface EntityState<V> {
  ids: string[] | number[];
  entities: { [id: string | id: number]: V };
}

in the above interface you can picture that something would use the interface like this

class AnyClassname implements EntityState<ObjectName>{ ... }

ObjectName would be the object you want used as an entity or database entity.

the ids key is an array of either number or string and the entities key is essentially an object of the key (whether they are numbers or string with a value of ObjectName

Here is what it could look like (ObjectName is how I am representing an object, it could be a Todo or a User):

{
    ids: ['1','2'],
    entities: {
        '1': {
            ...ObjectName
        }
    }
}
Brenton
  • 84
  • 3
  • so means the type will be an object? – Leo Ku Jul 15 '19 at 15:18
  • 1
    @LeoKu it may be any type – zerkms Jul 15 '19 at 22:14
  • 1
    @LeoKu I just used an object as an example. Typescript Generics is what it is and chances are if you were storing a bunch of `User` entities each `User` would have a `username`, `id`, and other data that would represent that user. The whole typescript generic thing is so you substitute `` which I am guessing they used V to represent Value which is beside the point as the letter could be anything and you will usually see it as to represent Type. – Brenton Jul 16 '19 at 05:41