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

common-ngx-settings: Settings Service depends on an open subscription to init update settings when updateSettings is called. #205

Open
Proantagonist opened this issue Apr 19, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@Proantagonist
Copy link
Collaborator

updateSettings should be able to correctly update state settings without depending on an open subscription on init.

Example:

    this.settingsService
      .init({
        storage: {
          subKey: 'modals'
        },
        settings: {
          beta_acknowledge: {
            value: false,
            persistent: true
          }
        }
      })
      .pipe(
        filter((settings) => {
          return settings['beta_acknowledge'] === false;
        })
      )
      .subscribe(() => { // The subscription is needed, otherwise when the modal closes and the call to update app settings does not execute correctly, leading to the modal opening again on page refresh
        this.openBetaModal();
      });
  }
this.ms
      .open<boolean>(BetaPromptComponent)
      .pipe(
        filter((acknowledged) => {
          return acknowledged;
        })
      )
      .subscribe(() => {
        this.ss.updateSettings({ // Will not work if the settingsService `init` call is not subscribed to
          beta_acknowledge: true
        });
      });

Commit to replicate: aefb7cf

File: libs\aggiemap\ngx\core\src\lib\pages\map\map.component.ts

@Proantagonist Proantagonist added the enhancement New feature or request label Apr 19, 2022
@Proantagonist Proantagonist self-assigned this Apr 19, 2022
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
Development

No branches or pull requests

1 participant