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

117
Views
Pass argument to readable store in Svelte

is there someway to pass an argument to readable store in svelte ? I have the next code:

export const worker = readable(
    [], async (set) => {

        const response = await fetchAPI()
        set(response)
        
        const interval = setInterval(async () => {
            const response = await fetchAPI()
            set(response)
        }, 10000)
})

I want pass an argumeto to that readable function with the response of the api to set the result of it via set().

Thanks

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can access any variables that are in scope, so you can "pass" a variable from outside the readable's function.

export function worker(arg) {
   return readable([], async set => {
      const response = await fetchAPI(arg); // arg is in scope here
      // ...
   });
}
about 4 years ago · Santiago Trujillo Report
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!