Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(component): clear LetDirective view when replaced observable is in suspense state #3671

Commits on Nov 22, 2022

  1. feat(component): clear LetDirective view when replaced observable i…

    …s in suspense state
    
    BREAKING CHANGES:
    
    The `LetDirective` view will be cleared when the replaced observable is in a suspense state. Also, the `suspense` property is removed from the `LetViewContext` because it would always be `false` when the `LetDirective` view is rendered. Instead of `suspense` property, use the suspense template to handle the suspense state.
    
    BEFORE:
    
    The `LetDirective` view will not be cleared when the replaced observable is in a suspense state and the suspense template is not passed:
    
    ```ts
    @component({
      template: `
        <!-- When button is clicked, the 'LetDirective' view won't be cleared. -->
        <!-- Instead, the value of 'o' will be 'undefined' until the replaced -->
        <!-- observable emits the first value (after 1 second). -->
        <p *ngrxLet="obs$ as o">{{ o }}</p>
        <button (click)="replaceObs()">Replace Observable</button>
      `
    })
    export class TestComponent {
      obs$ = of(1);
    
      replaceObs(): void {
        this.obs$ = of(2).pipe(delay(1000));
      }
    }
    ```
    
    AFTER:
    
    The `LetDirective` view will be cleared when the replaced observable is in a suspense state and the suspense template is not passed:
    
    ```ts
    @component({
      template: `
        <!-- When button is clicked, the 'LetDirective' view will be cleared. -->
        <!-- The view will be created again when the replaced observable -->
        <!-- emits the first value (after 1 second). -->
        <p *ngrxLet="obs$ as o">{{ o }}</p>
        <button (click)="replaceObs()">Replace Observable</button>
      `
    })
    export class TestComponent {
      obs$ = of(1);
    
      replaceObs(): void {
        this.obs$ = of(2).pipe(delay(1000));
      }
    }
    ```
    markostanimirovic committed Nov 22, 2022
    Configuration menu
    Copy the full SHA
    ac9412b View commit details
    Browse the repository at this point in the history