Closed friendlymahi closed 3 years ago
Hi @friendlymahi Thank you for your report! As you can imagine, introducing two separate history managers might lead to some serious issues or unexpected glitches. As for now, Page Model Manager is tightly coupled with React Router, but based on your feedback the note has been taken to make it more flexible in the future.
I'm glad that you have found a workaround for your problem. As for now, we cannot support you any further, we will take this under consideration for future plans working on page model manager.
@blackbyte-pl thank you so much for your response and explaining the reasoning. I have one question. Spa model manager is react or angular agnostic. Am I right? If so let's say I create a separate browser history object without using react router is there a possibility for making this work? Even though the workaround works I have a constant reminder on my browser console that model client is not initialized even though it was and was able to obtain the model Json on every call after htmlt5 history push. Not sure if my questions see very vague or overwhelming, if so please pardon me. Thanks
In case if anyone is still facing the issue -
ERROR Error: Uncaught (in promise): Error: ModelClient is undefined. Call initialize first! Error: ModelClient is undefined. Call initialize first! at Object.get modelClient [as modelClient] (cq-spa-page-model-manager.js:1)
Update the node dependencies to: "@adobe/aem-spa-component-mapping": "^1.1.1", "@adobe/aem-spa-page-model-manager": "^1.3.11",
I am using
"@adobe/aem-angular-editable-components": "^1.4.0",
"@adobe/aem-spa-component-mapping": "^1.1.1",
"@adobe/aem-spa-page-model-manager": "^1.4.0",
and still getting the ModelClient is undefined
error
Same here, any updates?
Background In our application we already have custom routing implementation for soft loading content from AEM. Now we are integrating SPA editor. We also use Redux in our application. Our past experiences state that Redux and React Router are not the best combination for usecases. And our implementation is used across many websites within our organization. So usage of React Router may not be viable in near future.
Issue Description With in our custom routing implementation we already use HTML5 API for updating URLs. Now, if we don't use React Router and invoke ModelManager to initialize the root model or just the current page, using a custom model client that extends ModelClient class as we have different endpoints with additional parameters, for the first time AEM editor loads perfectly fine. Now we have a button where the action upon click is to invoke HTML5 API to navigate to a different page. We have written a custom binding that shall insert new page path into model store followed by getData to retrieve model for new page. Now in this process some how the custom model client becomes null the following error appears and doesn't load the new page content even though custom model client already retrieved the data.
VM590401 aem-spa-page-model-manager.js:1 Uncaught (in promise) Error: ModelClient is undefined. Call initialize first! at Object.get modelClient [as modelClient] (VM590401 aem-spa-page-model-manager.js:1) at Object._checkDependencies (VM590401 aem-spa-page-model-manager.js:1) at eval (VM590401 aem-spa-page-model-manager.js:1)
Package version "@adobe/aem-react-editable-components": "^1.0.0", "@adobe/aem-spa-component-mapping": "^1.0.0", "@adobe/aem-spa-page-model-manager": "^1.0.0",
To Reproduce Steps to reproduce the behavior:
Expected behavior ModelManager API should allow more control towards switching the page being viewed without throwing any errors
Screenshots Error description should enough. if desired will attach screenshots when some one requests for.
Additional context After repeated trials and info from https://stackoverflow.com/questions/60331739/render-aem-pages-in-react-dynamically-independently-of-url-path# decided to re-initialize (instead of get data) the model manager every time we have a new page with new instance of custom client it works fine.