Sorry for the unclear title, I'm struggling to phrase this question concisely!
I'm attempting to create a class:
class Stream<Template<T,K,I>>
I realize this is not the correct syntax. So far, I have...
class Stream<T extends object, K, I extends string> {
constructor(ledger: Ledger, template: Template<T, K, I>) {
this.ledger = ledger;
this.stream = ledger.streamQuery(template);
}
private ledger: Ledger;
private stream: DamlStream<T, K, I, readonly CreateEvent<T, K, I>[]>;
...
My goal is to create a generic Stream where a stream can be defined as:
stream: Stream<Record>
where Record
is a Template<T,K,I>
.
I don't want the class definition to include Stream<T,K,I>
because the T
, K
, and I
of the Record
are messy, autogenerated hash strings. It wouldn't look good.
Summary:
I want to define a stream as stream: Stream<Record>
, not
stream: Stream<RecordT, RecordK, RecordI>
If you have any helpful suggestions, please let me know!
Cheers
EDIT: (Further clarification)
I'd like to instantiate the Stream class with the constructor like this:
stream = new Stream(ledger, StorageRecord)
. Here, StorageRecord
is a type generated from the backend and is of type Template<T,K,I>
where K
, T
, and I
sometimes have very lengthy, unattractive names.
The issue arises when trying to define a Stream
class member as stream: Stream<...>
.
I simply want to use Stream<StorageRecord>
, for example.
I can't define Stream
as class Stream<T>
because ledger.streamQuery
necessitates a Template
argument.
I can't define Stream
as
class Stream<T extends Template>
because Template
itself is generic.
I need to retain T
, K
, and I
since they are necessary in the class too.