HowProgrammingWorks / HowProgrammingWorks/AsynchronousProgramming

`.do` arguments not passed correctly

Open
#14 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
23
Forks
26
PR merge metrics
No merged PRs in 30d

Description

The current implementation of the callback chain in 5a-chain passes data from the previous callback but doesn't pass arguments explicitly mentioned in .do().

In usage example readConfig callback is expected to receive myConfig as an argument.

const startChain = chain()
  .do(readConfig, 'myConfig')
  .do(selectFromDb, 'select * from cities')
  .do(getHttpPage, 'http://kpi.ua')
  .do(readFile, 'README.md');

However it receives undefined instead.

So if callbacks would really depend on the previous one the chain would fail once it was called.

Also, should only the first callback in the chain receive an explicit argument, and the following ones receive their arguments from the previous one? Or should they receive both explicit and implicit arguments?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the callback-chain implementation in 5a-chain and the usage example showing readConfig, selectFromDb, getHttpPage, and readFile. Trace how arguments are passed through each .do() call, then verify that the documented callbacks receive the expected explicit and previous-callback arguments instead of undefined.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.