Proposal: Selector/Select Expression

2019-06-21 Thread Simon Farrugia
Selector/Select Expression Doing functional & reactive programming is currently really verbose in JavaScript. Hopefully this issue will be alleviated with the addition of the pipe operator in the near future. One things you end up doing most when doing fp is doing simple selections (mappings

Re: Proposal: Selector/Select Expression

2019-06-21 Thread Scott Rudiger
I can appreciate the intent of the proposal. 👍 Minor nit with one of the examples: // user[] => email[] (With Arrays) const getEmailsList = users => users.map(user => user.contacts.email); const getEmailsList = .map(.contacts.email); ``` I would think with the proposal you'd still need to re

Re: Awaiting block expression

2019-06-21 Thread Augusto Moura
The do expressions proposal[1] had some discussions about having a `async` variant[2] you should give it a look Is the same concept you are proposing [1]: https://github.com/tc39/proposal-do-expressions [2]: https://github.com/tc39/proposal-do-expressions/issues/4 Em sex, 21 de jun de 2019 às 03:

Awaiting block expression

2019-06-21 Thread guest271314
```await [null].reduce(async user => fetch('/image/'+ (await user).image).json(), fetch('/user/'+id).json())``` Or use ```Promise.all()```. Or an immediately invoked async arrow function where a value is ```return```ed from the function. How do you propose to get the values declared within block

Re: Proposal: Selector/Select Expression

2019-06-21 Thread Adam Eisenreich
This new notation will enable you a new way to create functions `.map(...)` produces `(parameter) => parameter.map(...)`, it is not evaluated, it is a function definition I cannot say I like it. To me it is less readable, confusing to be exact. Anything leading with `.` (dot), seems unusua

Re: Proposal: Selector/Select Expression

2019-06-21 Thread Simon Farrugia
Thanks for the feedback Scott, Regarding your concern about the array example, both expressions are valid but different: This (what you wrote) would map the array of users to an array of emails and declare getEmailsList as an array of emails. ``` const getEmailsList = users.map(.contacts.email);

Proposal: Exposing native scroll as API

2019-06-21 Thread Adam Eisenreich
Hello everyone. I think browsers should expose the native scroll as API.  Possible uses: * Native-like scroll in canvas apps (games) - Google's Proxx (https://proxx.app/) had to do quite a bit of magic to have native scroll for a game. * Camera controls for touch device (3D model preview) Gestur

Re: Proposal: Exposing native scroll as API

2019-06-21 Thread guest271314
What is meant by "native scroll"? ``` window.scrollTo({ left: leftValue, // e.g., element.getBoundingClientRect().left top: topValue, // element.getBoundingClientRect().top behavior: "smooth" }); ``` ? On Fri, Jun 21, 2019 at 2:07 PM Adam Eisenreich wrote: > Hello everyone. I think brow

Re: Awaiting block expression

2019-06-21 Thread Augusto Moura
Actually... You are proposing a `await` in a block, and a implicit await in all Promile-like expressions (or every expression) in the block, that's a totally different beast I don't think the implicit await part can be easily implemented neither is a good idea, the code flow can get really confusi

Re: Re: Proposal: Exposing native scroll as API

2019-06-21 Thread Adam Eisenreich
I mean, that there should be an API that would say, how an element would scroll, if it was in place of for example a ``. ``` const scrollArea = new ScrollArea(canvasElement, { borderBox: 'unlimited', // Default would be the element //viewPort: '100#200' }); scrollArea.addEventLisener('scro

Re: Re: Proposal: Exposing native scroll as API

2019-06-21 Thread guest271314
Not following what > if it was in place of is intended to mean? It is currently possibble to scroll to any portion of the viewport and get the current position of any element during `scroll` event. What is being proposed that is not already possible? On Fri, Jun 21, 2019 at 2:30 PM Adam Eisenr

Re: Awaiting block expression

2019-06-21 Thread Colin Cheng
How about like do expression: ```javascript const image = await (async do {     const user = await fetch('/user/'+id).json();     await fetch('/image/'+user.image).json() }) ``` On Jun 21, 2019 14:41, Tobias Buschor wrote: > > As there are more and more async apis, i would like to have a bloc

Re: Proposal: Exposing native scroll as API

2019-06-21 Thread Adam Eisenreich
If you want to have native scrolling experience for `` you need to either implement your own scrolling behaviour, or you will create `` of size much bigger than screen, that way it overflows screen and shows scollbars, but then you must only render on part of canvas as most is hidden. I would

Re: Proposal: Selector/Select Expression

2019-06-21 Thread Scott Rudiger
Got it, that make sense. I like the motivation behind the proposal. If it moves forward, I could see people possibly not liking (and bikeshedding) on the bare dot syntax, especially as it adds a new form of defining a function. Although, personally, I got used to it in less than a minute. On Fri,

Re: Proposal: Exposing native scroll as API

2019-06-21 Thread Claude Pache
> Le 21 juin 2019 à 16:07, Adam Eisenreich a écrit : > > Hello everyone. I think browsers should expose the native scroll as API. > > Possible uses: > * Native-like scroll in canvas apps (games) - Google's Proxx > (https://proxx.app/) had to do quite a bit of magic to have native scroll for

Re: Re: Proposal: Selector/Select Expression

2019-06-21 Thread Simon Farrugia
New syntax will always look a bit odd at first until we get used to it. I sometimes find nested arrow functions a bit confusing to understand where one function starts and where it ends particularly when they are one liners. This syntax is more concise and personally I find it more readable. Reas

ECMAScript feature suggestion: Streaming Array items through filter/map/reduce functions

2019-06-21 Thread Roma Bronstein
Hi, It's my first time suggesting a feature, hope I'm doing it correctly. I really like using Array.prototype.map(), Array.prototype.reduce() and all related functions. The code is more readable and it looks better. However, when I want to write performance sensitive code, chaining these function

Re: ECMAScript feature suggestion: Streaming Array items through filter/map/reduce functions

2019-06-21 Thread Oliver Dunk
This seems like a good place to share the idea, and it’s helpful that you provided use cases etc. Is there a reason why you prefer the proposed syntax over the forEach loop you mentioned? Personally I like how the forEach is easy to understand, but maybe there are other examples of when the str

Re: ECMAScript feature suggestion: Streaming Array items through filter/map/reduce functions

2019-06-21 Thread Roma Bronstein
Thanks Oliver for the quick response. The problem for me with forEach, that it's pretty much like a for loop. Anything can go inside the iteration logic. However with filter/map/reduce/some/every functions, the intention is explicit. Also you don't need to implement basic array operations that the

Re: CMAScript feature suggestion: Streaming Array items through filter/map/reduce functions

2019-06-21 Thread Gus Caplan
I always forget to reply-all :) -- Forwarded message - From: Gus Caplan Date: Fri, Jun 21, 2019, 16:34 Subject: Re: ECMAScript feature suggestion: Streaming Array items through filter/map/reduce functions To: Roma Bronstein I'm working on a proposal that adds generalized iterat

Re: CMAScript feature suggestion: Streaming Array items through filter/map/reduce functions

2019-06-21 Thread Roma Bronstein
Thanks Gus. I'm not sure I fully understand the proposal docs (first time I'm reading something like this , OMG...) Can you please show a quick example of how would you streamline an array through filter, map and then reduce? T

Re: ECMAScript feature suggestion: Streaming Array items through filter/map/reduce functions

2019-06-21 Thread Bergi
Hi! However, when I want to write performance sensitive code, chaining these functions is not a good approach. const b = a.filter().map() will require 2 traversals over the whole array, up to 2*N iterations (if the filter passes all items). Actually, the number of passes hardly matters. It's

Re: ECMAScript feature suggestion: Streaming Array items through filter/map/reduce functions

2019-06-21 Thread Roma Bronstein
Thanks for the reply Bergi. Correct me if I'm wrong but writing something like: const b = Array.from(a.values().filter(…).map(…)) Still requires 2 iterations over the array. You're theoretically right that the running time complexity is still linear. However with the introduction of the ability t

Re: Proposal: Exposing native scroll as API

2019-06-21 Thread guest271314
What are you NOT able to output right now relevant to programmatically scrolling using existing DOM methods, Web Animations API, and/or CSS? Have you filed an issue at browsers, WHATWG HTML, and WHATWG DOM? On Fri, Jun 21, 2019 at 3:33 PM Adam Eisenreich wrote: > If you want to have native scrol

Re: Re: Proposal: Selector/Select Expression

2019-06-21 Thread Bob Myers
Personally, I'm a huge fan of this proposal. It would integrate into the language the extremely frequent idiom of defining a pick/pluck like function. There is ample prior art in the form of Ramda's pick function .as well as `pluck` in RxJS. In fact, this exact prop