lawndart icon indicating copy to clipboard operation
lawndart copied to clipboard

Suggestion for abstract class Store<V> -- store.items()

Open mbelchin opened this issue 11 years ago • 1 comments

I would like to do a suggestion for abstract class Store<V>, it has .keys() and .values() methods to retrieve keys and values, what about if you want to retrieve both of them?

Currently you can do something like this:

db.open().then((_) {
      store.keys()
      .listen((key) {
        store.getByKey(key).then((value) => print('$key, $value'));
      });
  });

But I feel the code become more ugly. Something like this would be awesome:

db.open().then((_) {
    store.items() 
    .listen((key, value) => print('$key, $value'));
 });

Thanks and regards. Moises Belchin.

mbelchin avatar Mar 07 '13 12:03 mbelchin

Interesting, thanks for the report! The Stream API lets me return only a single object in listen(), so I can't return both key and value via listen unless I wrap them both in a single object.

sethladd avatar Mar 08 '13 07:03 sethladd