Promise based
See original GitHub issueHello,
In order to avoid callback hell, the library could use promises. I’ve tried wrapping stuff in promises but there are context issues (this
is undefined)
eg 1:
es.getEventStream({ aggregateId: 'someId' })
.then(stream => { /* do some commits*/ })
.catch(error => console.error(error));
eg 2:
es.getNewId()
.then(id => es.getEventStream({ aggregateId: id }))
.then(stream => { /* do some commits*/ })
.catch(error => console.error(error));
Issue Analytics
- State:
- Created 6 years ago
- Comments:15 (5 by maintainers)
Top Results From Across the Web
Promise - JavaScript - MDN Web Docs
The Promise object represents the eventual completion (or failure) of an asynchronous operation and its resulting value.
Read more >Promise - The Modern JavaScript Tutorial
A promise is a special JavaScript object that links the “producing code” and the “consuming code” ... Create a promise-based alternative.
Read more >Promise-Based Management: The Essence of Execution
Promise -based management empowers individuals to act like true entrepreneurs within the organization—to spot opportunities, assemble the resources required to ...
Read more >JavaScript Promises - W3Schools
A JavaScript Promise object can be: ... The Promise object supports two properties: state and result. While a Promise object is "pending" (working),...
Read more >25. Promises for asynchronous programming - Exploring JS
Compared to callbacks as continuations, Promises have the following advantages: No inversion of control: similarly to synchronous code, Promise-based functions ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi Susanna, OT: greets from Rheinhausen to you and Golo 😉 Nice that you will maintain this project!
From architecture point of view it makes a lot more sense to implement native node streams instead of promises, it is far more natural, supported natively by mongodb ( maybe also by other adapters ), could allow processing virtually any amount of events without memory considerations and in general is a perfect fit for this job.