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

70
Views
How to fetch new info from database without closing mounted components

I`ve been working in a Svelte SaaS recently and there is an mobile app that updates my db constantly, so then I need to fetch info from db again every 1 minute.

The problem is: Inside some hierarchical components, I have modals that close whenever I update my promise. Is there something that can be done so my user doesn`t need to reopen the modal?

Here is the code that updates my promise ( finishedPromise )

    onMount(async () => {
        const depots = await depotsPromise;
        depots.forEach(depot=> checkedDepots.add(depot._id));
        toRouteFilter = toRouteFilter;
        let isOnline = setInterval(() => {
            DataStorage.get('finished',true).then(finisheds=> finishedPromise = Promise.resolve(finisheds));
        }, 60*1000);
        return function(){
            clearInterval(isOnline);
        }
    });

Rendering the components:

  <div>
    {#await filteredRoutes}
        Carregando...
    {:then routes}
        {#if selectedTab == 1}
            <ManageDelivery
                routes={routes}/>
        {:else}
            <MapDelivery />
        {/if}
    {/await}
  </div>

My modals are rendered inside the component ManageDelivery, only by using a local inside flag of showModal as true or false.

about 4 years ago · Santiago Gelvez
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!