Skip to content

Commit

Permalink
feat: Add route listener and update routeChanged method
Browse files Browse the repository at this point in the history
The route listener is added to the Productled class constructor to listen for route changes. The routeChanged method is updated to be private and accept a URL parameter. This change ensures that the routeChanged method is only called internally and allows the Productled class to execute the appropriate hooks for the new route.
  • Loading branch information
hasith committed Sep 2, 2024
1 parent b74f5d2 commit 37a1bc9
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 13 deletions.
4 changes: 2 additions & 2 deletions packages/@productled/core/src/Productled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Productled {
this.documentService = new DocumentService();
this.configStore = new ConfigStore();
this.routeListener = new RouteListener();
this.routeListener.addListener(this.routeChanged.bind(this));
}

/**
Expand Down Expand Up @@ -58,7 +59,7 @@ class Productled {
* @param {string} url - The URL of the new route
* @returns {Promise<void>}
*/
public routeChanged(url: string) {
private routeChanged(url: string) {
const hooks = this.hookStore.getHooks(url);

const hookExecuter = new HookExecuter(this.pluginStore, this.documentService);
Expand All @@ -78,7 +79,6 @@ class Productled {
// Get the hooks for the plugin and add them to the hook store
const hooks = this.configStore.getHooks(pluginName);
this.hookStore.addHooks(hooks, pluginName);
this.routeListener.addListener(this.routeChanged.bind(this));
}

}
Expand Down
4 changes: 0 additions & 4 deletions packages/samples/react-sample/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@ import Page from './Page'; // Import the existing page component
import HomePage from './HomePage'; // Import another page component (create this if it doesn't exist)
import SubPage from './SubPage'; // Import the sub-page component (create this if it doesn't exist)
import NavBar from './NavBar';
import ProductledInit from './ProductledInit';

const App: React.FC = () => {



return (
<Router>
<div className="App">
<ProductledInit/>
<NavBar /> {/* Use the NavBar component */}
<Routes>
<Route path="/" element={<HomePage />} />
Expand Down
7 changes: 0 additions & 7 deletions packages/samples/react-sample/src/ProductledInit.tsx

This file was deleted.

0 comments on commit 37a1bc9

Please sign in to comment.