- From: Ian Kilpatrick via GitHub <sysbot+gh@w3.org>
- Date: Mon, 09 Apr 2018 08:00:33 +0000
- To: public-houdini-archive@w3.org
bfgeek has just created a new issue for https://github.com/w3c/css-houdini-drafts:
== [css-layout-api] Generator vs. Promise design for the API ==
There isn't actually a large difference between the two APIs from just looking at the script, i.e.
```js
*layout(children) {
const fragment = yield children[0].layoutNextFragment();
}
```
```js
layout(children) {
const fragment = await children[0].layoutNextFragment();
}
```
There are various pros/cons of each of these.
Generator:
- Pro: May be faster wrt. bindings.
- Pro: More restrictive API, can't `await` on other APIs which might leak into the LWGS.
- Con: Less obvious error handling to for web developers.
- Con: Less obvious API as this pattern isn't common, and not many people use them (generators).
Promise:
- Pro: More obvious error handling.
- Pro: Common pattern for developers.
Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/750 using your GitHub account
Received on Monday, 9 April 2018 08:00:37 UTC