question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hello,

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:closed
  • Created 6 years ago
  • Comments:15 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
blissicommented, Sep 4, 2020

Hi Susanna, OT: greets from Rheinhausen to you and Golo 😉 Nice that you will maintain this project!

2reactions
nanovcommented, May 30, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found