public-transport / fpti-js

Standardized API for public transportation client libraries in JavaScript.
Creative Commons Attribution Share Alike 4.0 International
9 stars 0 forks source link

Promise should be an async generator? #12

Open pietercolpaert opened 4 years ago

pietercolpaert commented 4 years ago

Cool work! In stations.all you implement a readable, and all other methods return a Promise.

Instead of a Promise, would it make sense to yield more responses and have an async generator instead? Blog post on this: http://thecodebarbarian.com/async-generator-functions-in-javascript.html

That could be the default return type for all the functions. This way, you can always request more stations, and the function should always keep looking for more entities.

That’s the approach we take in Planner.js

derhuerst commented 4 years ago

This would a cool step to further unify different API endpoints & data sets!