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

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<Value>   |
| **Temporal** | Promise<Value> | Observable<Value> |



---
Reply to this email directly or view it on GitHub:
https://github.com/w3c/findtext/issues/19#issuecomment-163700950

Received on Thursday, 10 December 2015 17:50:41 UTC