robertwb commented on PR #22134:
URL: https://github.com/apache/beam/pull/22134#issuecomment-1180797546

   To do this one would have to add methods like flatMap to the Promise 
prototype (affecting all Promises across Javascript) or return a subclass 
(well, really a hierarchy of subclasses) of Promise (which I looked into and 
looks pretty sketchy). This would work if Promise could be a proxy object to 
the type it was promising, but it's not. 
   
   It looks like another alternative is 
   
   ```
   lines
       .invoke("map", (s: string) => s.toLowerCase())
       .invoke("flatMap", function* splitWords(line: string) {
         yield* line.split(/[^a-z]+/);
       })
       .invoke("apply", beam.countPerElement())
   ```
   
   but this is still a bit icky, and looses type safety. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to