Re: [css-houdini-drafts] [css-paint-api] Use JS export instead of registerPaint

> > What happens if I export a constant? Or a function?
>
> Same thing that happens if you "registerPaint" a constant or function.

Right. Currently, that throws. That means that all subsequent calls to `registerPaint` would never get executed. So we’d have to either live with that or catch them for you, but then you have no way of knowing if all your exports actually got processed. This also ties into the “reusing modules” point: 
If I use a module somewhere outside a paint worklet, paint classes would just be vanilla classes. But if I export anything other than paint classes (consts, functions,...) re-using that module becomes problematic due to the reasons outlined above. It defeats the purpose of modularization (i.e. bundling data and functionality that belongs together).

That being said, I can see why your proposed way is desirable in terms of ergonomics. Seeing that you can build a declarative API on top of the imperative API with the 3 lines of code above and that the same is not true for the reverse case AFAICT, I think this is indeed the more low-level approach.

-- 
GitHub Notification of comment by surma
Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/564#issuecomment-359268850 using your GitHub account

Received on Sunday, 21 January 2018 18:23:27 UTC