WebAPIKit icon indicating copy to clipboard operation
WebAPIKit copied to clipboard

Represent at least some union types as protocols

Open MaxDesiatov opened this issue 2 years ago • 1 comments

Currently, WebGL 1.0, WebGL 2.0, and WebGPU can't be split into separate modules as targets, as enum RenderingContext wraps all available context types and needs to have all of them in scope.

If RenderingContext were a protocol, we could declare it in some "base" module and move GPUCanvasContext, WebGLRenderingContext, and WebGL2RenderingContext to their own respective modules adding a conformance on them to that protocol.

I also thought about subclassing, but that clearly won't work due to the lack of multiple class inheritance. These types already inherit from JSBridgedClass, and protocols are the suggested instruments of achieving multiple inheritance in Swift.

MaxDesiatov avatar May 25 '22 09:05 MaxDesiatov