Coder Social home page Coder Social logo

Multiple instances of the same @defered component are instantiated in a random order with esbuild (but not webpack) about angular HOT 1 CLOSED

simeyla avatar simeyla commented on May 8, 2024
Multiple instances of the same @defered component are instantiated in a random order with esbuild (but not webpack)

from angular.

Comments (1)

AndrewKushnir avatar AndrewKushnir commented on May 8, 2024

@simeyla the @defer feature by design can not guarantee the order in which blocks would be loaded and executed, so relying on the order can lead to breakages and the behavior that you've described.

There are a couple options you may consider:

  1. Wrap a larger section into a defer block and have multiple components there:
  @defer() {
    <app-defered />
    <app-defered />
    ...
  }
  1. Add extra logic into the app code to ensure the order:
@if (loadedCount === 0) {
  @defer() {
    <app-defered />
  }
}

// ... somewhere in another part of the template ...
@if (loadedCount === 1) {
  @defer() {
    <app-defered />
  }
}

The loadedCount could be increased once a new instance of a component is created.

I'll close this ticket for now, since this behavior is expected - there is no guarantee around an exact order in which @defer blocks are loaded and invoked.

from angular.

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.