Skip to content

Commit

Permalink
Cleaning router core
Browse files Browse the repository at this point in the history
  • Loading branch information
John Nolette committed Sep 2, 2019
1 parent 6091a75 commit ac8a1d2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion dist/router.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/interfaces/router.d.ts
Expand Up @@ -18,10 +18,10 @@ export interface IRouterArgs {
}

export interface IRouter {
$location: IRouterLocation;
$previous: IRouterLocation,
$tools: IRouterTools;
config: IConfig;
location: IRouterLocation;
previous: IRouterLocation,
tools: IRouterTools;
running: boolean;
legacySupport: boolean;
listenerKey?: number;
Expand Down
17 changes: 10 additions & 7 deletions src/router.ts
Expand Up @@ -19,10 +19,10 @@ class RouterTools implements IRouterTools {
}

class Router implements IRouter {
public $location: IRouterLocation;
public $previous: IRouterLocation;
public $tools: IRouterTools;
public config: IConfig;
public location: IRouterLocation;
public previous: IRouterLocation;
public tools: IRouterTools;
public running: boolean;
public legacySupport: boolean;
public listenerKey?: number;
Expand All @@ -33,7 +33,7 @@ class Router implements IRouter {
this.client = args.client;
this.running = false;

Object.defineProperty(this, 'location', {
Object.defineProperty(this, '$location', {
get: () => {
return {
hash: window.location.hash,
Expand All @@ -49,15 +49,18 @@ class Router implements IRouter {
}

watch () {
// TODO: make ambiguous, must be able to run only on route change w/ interval

if (this.running) {
// let navigated =
if (this.client && this.client.onNavigate) {
this.client.onNavigate({
router: this,
location: this.location,
previous: this.previous,
location: this.$location,
previous: this.$previous,
});

this.previous = this.location;
this.$previous = this.$location;
}
}
}
Expand Down

0 comments on commit ac8a1d2

Please sign in to comment.