GithubHelp home page GithubHelp logo

Comments (7)

m0t0r avatar m0t0r commented on July 17, 2024 1

Yeah, that works fine. Thanks a lot!

from angular-playground.

jschwarty avatar jschwarty commented on July 17, 2024

Can you post an example of your stats-widget.component.sandbox.ts?

from angular-playground.

m0t0r avatar m0t0r commented on July 17, 2024

Hi, @jschwarty, thanks for your reply. It's working fine now, I was doing something wrong.

Will leave a working example here as a reference:

context: {
      data: (function () {
        return new Promise(resolve => {
          setTimeout(() => resolve({
            value: 3150,
            title: 'Stats 1',
            description: 'Stats description 1'
          }), 1000);
        });
      })()
    },
template: '<app-stats-widget [data]="data | async"></app-stats-widget>'

but there is another problem. When I switch between sandbox cases using quick search it looks like all cases are already run so I have to refresh page to actually rerun and see the delay I need. Is it possible to run each sandbox case only when you navigate to it and rerun each time you open it again ? I can close this issue and open another one if required.

from angular-playground.

jschwarty avatar jschwarty commented on July 17, 2024

@m0t0r You can leave this one open. I will use what you posted to take a look at the issue you are experiencing and get you an answer on that. I might not be able to get to it today but I will get back to you soon on it.

from angular-playground.

m0t0r avatar m0t0r commented on July 17, 2024

@jschwarty that's fine, thanks a lot!

from angular-playground.

m0t0r avatar m0t0r commented on July 17, 2024

@jschwarty, do you have any updates ?

from angular-playground.

jschwarty avatar jschwarty commented on July 17, 2024

It's because you have an IIFE there, and the *.sandbox.ts file gets ran as soon as you choose any of the scenarios for that sandboxOf component. So that code is getting run once in that file when the sandboxOf function is called.

You could create an accessor so that it is called on execution of each component scenario run:

context: {
  get data() {
    return new Promise(resolve => {
      setTimeout(() => resolve({
        value: 3150,
        title: 'Stats 1',
        description: 'Stats description 1'
      }), 1000);
    });
  }
}

from angular-playground.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.