Re: [css-houdini-drafts] [css-animationworklet] Avoid StatefulAnimatior/StatelessAnimator superclass and use existence of state() function (#850)

The Houdini Task Force just discussed `Avoid StatefulAnimatior/StatelessAnimator superclass and use existence of state() function`, and agreed to the following:

* `RESOLVED: accept majid's proposal to use a state() function's existence to detect statefulness, and drop the superclass check`

<details><summary>The full IRC log of that discussion</summary>
&lt;Rossen_> Topic: Avoid StatefulAnimatior/StatelessAnimator superclass and use existence of state() function<br>
&lt;TabAtkins> ScribeNick: TabAtkins<br>
&lt;Rossen_> github: https://github.com/w3c/css-houdini-drafts/issues/850<br>
&lt;TabAtkins> majidvp: Last year, we made a resolution on how to differentiate between stateful and statless animator<br>
&lt;TabAtkins> majidvp: Idea was to use two seaprte classes<br>
&lt;TabAtkins> majidvp: You inherit from whichever you want<br>
&lt;TabAtkins> majidvp: We lookeda t some different options: looking at property on aniamtor, o rlength of arguments, etc<br>
&lt;TabAtkins> majidvp: While trying to implement this, I realized there were complications<br>
&lt;TabAtkins> majidvp: So new idea I thinka ddresses the shortcomings<br>
&lt;TabAtkins> majidvp: Rather than requiring a superclass to be extended, we look at the existence of the state() function<br>
&lt;TabAtkins> majidvp: So if your animator implements the state() function, they're a stateful animator. If not, they're stateless.<br>
&lt;TabAtkins> majidvp: I think that's simpler. THe interface matches the contract.<br>
&lt;TabAtkins> majidvp: Problem with the superclasses is that it clashes with bringing your own class hierarchy.<br>
&lt;TabAtkins> majidvp: It'll cause people to just extend StatefulAnimator at the top of their hierarchy, which defeats the point.<br>
&lt;TabAtkins> majidvp: This seems more consistent with other worklets too - PaintWorklet and LayoutWorklet don't require extending a class.<br>
&lt;heycam> q+<br>
&lt;TabAtkins> AmeliaBR: An issue I see with that is that from a JS perspective, you can add a getter function on an instance.<br>
&lt;TabAtkins> AmeliaBR: I'm assuming you judge it at the registration stage.<br>
&lt;TabAtkins> AmeliaBR: What if you put one on the instance?<br>
&lt;TabAtkins> majidvp: Verify it at registration stage, like paint functions works.<br>
&lt;TabAtkins> majidvp: If you add state() later, it'll be ignored.<br>
&lt;TabAtkins> majidvp: We want it to be a single value at registration for the whole life.<br>
&lt;TabAtkins> TabAtkins: So like we'll do a Get on the class object, seeing if "state" returns a function, and make the decision based on that. This is similar to, say, Promises and .then()<br>
&lt;TabAtkins> AmeliaBR: I see some different examples, a state getter and a state method. So it's the method you're discussing?<br>
&lt;Rossen_> ack heycam<br>
&lt;TabAtkins> majidvp: yes<br>
&lt;heycam> https://tc39.es/ecma262/#sec-ordinaryhasinstance<br>
&lt;TabAtkins> heycam: In the first issue comment, you say the current superclass model we have to ask tc39 to add an operation, but I think it already exists.<br>
&lt;TabAtkins> majidvp: I started looking at this becuase I wasn't sure how to spec it, and AudioWorklet already does this, but they haven't correctly specced it.<br>
&lt;TabAtkins> majidvp: During that my new idea came up, and I think regardless of speccing, this is a better API design.<br>
&lt;TabAtkins> proposed resolution: accept majid's proposal to use a state() function's existence to detect statefulness, and drop the superclass check<br>
&lt;TabAtkins> RESOLVED: accept majid's proposal to use a state() function's existence to detect statefulness, and drop the superclass check<br>
&lt;TabAtkins> &lt;br type=lunch><br>
</details>


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

Received on Friday, 7 June 2019 17:09:45 UTC