Channel (Ungeneric) vs Channel<Object>

Hey there,

Was testing a bunch of stuff with Channels this morning and was wondering what was the difference between a Channel<Object> and a Channel (Ungeneric). From my limited understanding, they should achieve the same thing, but there’s obviously a difference I’m missing.

Thanks in advance :)

I would have loved to avoid this confusion, but the type system didn’t let me.
I would have liked to avoid the Channel (UnGeneric).

A Channel<T> is known to be a Channel (UnGeneric) at compile time.
At Runtime it turns out you also can cast any Channel<T> to a Channel<object> - or use the property ChannelOfObject. But the fact that any Channel<T> always is a Channel<Object> is something you can’t express in the type hierarchy. .Net doesn’t allow this.

Having non-generic interfaces on something generic is a well-established pattern in .Net though. So it’s not that bad. Non-generic interfaces are often usable when creating a dynamic UI, where only at runtime the type becomes clear - e.g. the type of a timeline track.

Being able to grab a Channel<Object> for any Channel<T> (or for any Channel (Ungeneric)) is great to have since you now can use all the operators like Merge (…) that work with any Channel<T>, so all of them are also working for a Channel<Object>.


Have to process that but thanks :)

1 Like