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

reset() and clear() do not refresh the page config #966

Open
ed-bird opened this issue Jan 22, 2020 · 1 comment
Open

reset() and clear() do not refresh the page config #966

ed-bird opened this issue Jan 22, 2020 · 1 comment

Comments

@ed-bird
Copy link
Collaborator

ed-bird commented Jan 22, 2020

When operating a Single Page Application (SPA), you will need to reload the configuration to faciliate switching between different types of webpage. For example:

  • Go from the homepage to a basic article (no markup to markup with "productID: norcaltribune.com:basic")
  • Go from a basic article to a premium article (markup with productId: "norcaltribune.com:basic" to markup with productId: "norcaltribune.com:premium"

At the moment, the existing methods reset() and clear() only clear the entitlements and open dialogs but do not reset the page config which means that the flow described above cannot currently be supported.

@ed-bird
Copy link
Collaborator Author

ed-bird commented Jul 14, 2020

A workaround for this is as follows:

  • Initialise swg.js manually when the application loads
  • For each article page:
    • Do not re-call subscriptions.init(), this will error out saying that the library is already configured
    • Call subscriptions.getEntitlements() and check the full entitlements response to see if any of the entitlements are valid
    • Do not use entitlements.enablesThis() as it will be based on the configuration on the original page, not necessarily the configuration on the current page

It would still be good for reset() and clear() to be updated to support this flow though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant