withBreak blocks

Peter Jaszkowiak p.jaszkow at gmail.com
Sat Feb 17 21:19:18 UTC 2018


Also, you can just use `return` if you're in a function:

```
const doWork = () => {
  // try catch omitted for brevity
  const response = fetchData();

  if (response.error) {
    log(response.message);
    return;
  }
  if (!response.data) {
    log("No data");
    return;
  }
  if (!response.data.todos) {
    log("No Todos");
    return;
  }

  return action({ data: response.data });
};
```

On Sat, Feb 17, 2018 at 2:17 PM, Oriol _ <oriol-bugzilla at hotmail.com> wrote:

> This is so close to your proposal, and already works right now:
>
> ```js
> block: {
>   if (response.error) {
>     log(response.message);
>     break block;
>   }
>   if (!response.data) {
>     log("No data");
>     break block;
>   }
>   if (!response.data.todos) {
>     log("No Todos");
>     break block;
>   }
>   return action({ data: response.data });
> }
> ```
>
> - Oriol
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180217/ceef34da/attachment.html>


More information about the es-discuss mailing list