Re: [css-houdini-drafts] Pure/idempotent representation

The class registration style is consistent with other houdini APIs e.g., [paint API](https://drafts.css-houdini.org/css-paint-api-1/).

As I pointed out in the other issue, the worklet global scope itself may be created/destroyed at will so all the code within its scope has to be idempotent/pure. AFAICT Javascript has no way to ensure a function is pure so this is best we can get and it also means that all three syntax are equivalent in terms of actual purity which is none. (/cc @bfgeek who is the expert here)

Also, note that in the proposed scheme, the UA may create a few (or just one) instance of the class and call the function with different inputs on the same object instance. Multiple animator instances does not means we will have 1:1 object instances in the worklet scope for them which is why the authors should write pure functions anyway.

The advantage of the class syntax is the ergonomics and its scoping.


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

Received on Wednesday, 29 August 2018 18:18:45 UTC