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

Do not use setTimeout() to emit the initial status #3

Open
jackwootton opened this issue Feb 12, 2020 · 1 comment
Open

Do not use setTimeout() to emit the initial status #3

jackwootton opened this issue Feb 12, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@jackwootton
Copy link

Regarding

  ngAfterViewInit() {
    // TODO: Find solution without timeout
    setTimeout(() => this.service.emitCookieStatus(), 1)
  }

Perhaps startWith can help:

  constructor(private readonly service: NgxCookieBannerService) {
    const firstValue = service.cookieExists(THE_COOKIE_NAME);

    this.isSeen = this.service.isSeen.pipe(
      startWith(firstValue),
      tap(status => {
        if (!status) {
          this._removeComponent = false;
        }
        if (status) {
          this._transition = 'bottomOut';
        }
      })
    );
  }
@evolkmann evolkmann added the enhancement New feature or request label Mar 15, 2020
@evolkmann
Copy link
Contributor

Hi @jackwootton, thanks for pointing this out. I just updated the repo to angular 9 and will work on this issue as soon as #5 is merged.

@evolkmann evolkmann self-assigned this Mar 15, 2020
@evolkmann evolkmann changed the title // TODO: Find solution without timeout Do not use setTimeout() to emit the initial status Mar 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants