An example, what createDrag returns below.
CodePudding user response:
'T' is going to be a type declared at run-time instead of compile time. The T variable could be any non-declared variable (I couldn't find a reference, but I would assume any valid set of characters that could be used for a variable names). Similarly in c#, if the type T represents is not a value type but a more complex type (class) or interface, it could be named/declared as TVehicle or TAnimal to help denote a valid type for future programmers (and could be considered best practice because just T is not intuitive). I prefer TSomething because I know that uppercase T means a generic type. WSometing or ASomething is also valid, but I just don't prefer it. (Microsofts APIs are almost always TContext or TEntity for example).
CodePudding user response:
The generic T
parameter of DragRef<T>
refers to the type of DragRef.data
. This is a field with user-defined semantics and can hold any data you want.
As an example, you can listen to the DragRef.cdkDragStarted
observable and attach data when you begin dragging. When you release, DragRef.cdkDragReleased
emits and you can refer back to the same data.