W3C home > Mailing lists > Public > public-annotation@w3.org > December 2015

Re: [findtext] Usage (or not) of Promise in ``search``

From: Benjamin Goering via GitHub <sysbot+gh@w3.org>
Date: Thu, 10 Dec 2015 17:49:53 +0000
To: public-annotation@w3.org
Message-ID: <issue_comment.created-163700950-1449769790-sysbot+gh@w3.org>
Promises are great for asynchronously getting a single future result.

It sounds like you want to leave the option open for 'search' to 
stream many results over time. In that case Promises are probably not 
so good. EventTarget is a decent interface.
```javascript
var results = whatever.search('...')
results.addEventListener('result', function (result) {});
```

or

whatever.search('...').forEach(function (result) {});

Generators are appropriate too, but futuristic.

You could also make it an iterator of promises.

More theory:
>From https://github.com/kriskowal/gtor

|              | **Singular**         | **Plural**              |
| :----------: | :------------------: | :---------------------: |
| **Spatial**  | Value                | Iterable&lt;Value&gt;   |
| **Temporal** | Promise&lt;Value&gt; | Observable&lt;Value&gt; |



-- 
GitHub Notification of comment by gobengo
Please view or discuss this issue at 
https://github.com/w3c/findtext/issues/19#issuecomment-163700950 using
 your GitHub account
Received on Thursday, 10 December 2015 17:49:55 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:54:43 UTC