withBreak blocks

Jacob Pratt jhprattdev at gmail.com
Sat Feb 17 21:24:09 UTC 2018


Can you provide a clear use case that can't (or shouldn't) be covered by
what others have mentioned?

jhpratt

On Sat, Feb 17, 2018 at 4:23 PM, sagiv ben giat <sagiv.bengiat at gmail.com>
wrote:

> That's not what i'm looking for.
> I may want to do some more things inside the function besides validations.
>
> Sagiv b.g
>
> On Sat, Feb 17, 2018 at 11:19 PM, Peter Jaszkowiak <p.jaszkow at gmail.com>
> wrote:
>
>> 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
>>>
>>>
>>
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>>
>
> _______________________________________________
> 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/55e4a466/attachment-0001.html>


More information about the es-discuss mailing list