Open kristianmandrup opened 7 years ago
Perhaps better to use this custom elements polyfill which is v0 and v1 compatible and super light weight!
I just found a similar adapter for Vue vue-custom-element which uses document-register-element that looks perfect for this objective!
import 'document-register-element/build/document-register-element';
If we could just get the typings right (as described above), we would finally be able to mix and match components across most modern front-end frameworks!
Time to upgrade to custom elements v1
Started upgrade effort here
First major problem (TypeScript type issue)
Which conflicts with run function interface
I guess the problem is
<So extends Sources, Si extends Sinks>
which conflicts withComponent = (sources: RequiredSources) => RequiredSinks;
so theRequired
types likely have to extendSources
andSinks
respectively?So this fixed the compiler issue:
Now is complains that
DisposeFunction
can't be converted toCycleExec
since it is missingsources
...export declare type DisposeFunction = () => void;
from@cycle/run/lib/index.d.ts
So I would think I need to "wrap" the
run
function to instead return aCycleExec
compatible interface.Return
CycleExec
But now the
sinks
returned are incompatible. Getting tricky! Thesetup(...)
function returns a run in the formfunction run(): DisposeFunction {
which still conflicts withCycleExec
so maybe I should change theCycleExec
type instead! I think that's the keyFinally got it down to:
My only type problem now is in the example app, where it is missing an
Index
signature inSinks
to be compatible?Otherwise, looks it like a pretty smooth upgrade :)