Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

51
Views
Add Promise-Chain part in reuseable function

I got a bunch of functions which consist of a simple promise-chain which is mostly individual, anyway for all my functions a small block in the promise-chain is the same for all chains.

Example:

function A() {
  DoSomethingA()
    .then(/* specific then block */)
    .then(/* general then block */)
    .then(/* general then block */)
    .then(/* specific then block */)
}

function B() {
  DoSomethingB()
    .then(/* specific then block */)
    .then(/* general then block */)
    .then(/* general then block */)
}

Now I want to have the "general then block" part be reusable variable/function so I can edit it for all functions at once when required. I just miss how I might handle this in the simplest way. Before and after the "general-then-blocks" there might be a undefined amount of "specific then blocks". The "general then blocks" always appear in this given order and always are exactly after each other.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!