refactor(common): rename UrlChangeEvent and UrlChangeListener to LocationChangeEvent and LocationChangeListener

These apis are not expected to be used anyone, hence I'm not documenting this change as a breaking.
This commit is contained in:
Igor Minar 2016-08-23 14:26:31 -07:00 committed by Victor Berchet
parent 8a2324f86a
commit 1f5a5895e5
9 changed files with 37 additions and 36 deletions

View File

@ -12,7 +12,7 @@ import {isPresent} from '../facade/lang';
import {Location} from './location';
import {APP_BASE_HREF, LocationStrategy} from './location_strategy';
import {PlatformLocation, UrlChangeListener} from './platform_location';
import {LocationChangeListener, PlatformLocation} from './platform_location';
@ -54,7 +54,7 @@ export class HashLocationStrategy extends LocationStrategy {
}
}
onPopState(fn: UrlChangeListener): void {
onPopState(fn: LocationChangeListener): void {
this._platformLocation.onPopState(fn);
this._platformLocation.onHashChange(fn);
}

View File

@ -7,7 +7,7 @@
*/
import {OpaqueToken} from '@angular/core';
import {UrlChangeListener} from './platform_location';
import {LocationChangeListener} from './platform_location';
/**
* `LocationStrategy` is responsible for representing and reading route state
@ -34,7 +34,7 @@ export abstract class LocationStrategy {
abstract replaceState(state: any, title: string, url: string, queryParams: string): void;
abstract forward(): void;
abstract back(): void;
abstract onPopState(fn: UrlChangeListener): void;
abstract onPopState(fn: LocationChangeListener): void;
abstract getBaseHref(): string;
}

View File

@ -12,7 +12,8 @@ import {isBlank} from '../facade/lang';
import {Location} from './location';
import {APP_BASE_HREF, LocationStrategy} from './location_strategy';
import {PlatformLocation, UrlChangeListener} from './platform_location';
import {LocationChangeListener, PlatformLocation} from './platform_location';
/**
@ -59,7 +60,7 @@ export class PathLocationStrategy extends LocationStrategy {
this._baseHref = href;
}
onPopState(fn: UrlChangeListener): void {
onPopState(fn: LocationChangeListener): void {
this._platformLocation.onPopState(fn);
this._platformLocation.onHashChange(fn);
}

View File

@ -34,8 +34,8 @@
*/
export abstract class PlatformLocation {
abstract getBaseHrefFromDOM(): string;
abstract onPopState(fn: UrlChangeListener): void;
abstract onHashChange(fn: UrlChangeListener): void;
abstract onPopState(fn: LocationChangeListener): void;
abstract onHashChange(fn: LocationChangeListener): void;
get pathname(): string { return null; }
get search(): string { return null; }
@ -55,9 +55,9 @@ export abstract class PlatformLocation {
*
* @experimental
*/
export interface UrlChangeEvent { type: string; }
export interface LocationChangeEvent { type: string; }
/**
* @experimental
*/
export interface UrlChangeListener { (e: UrlChangeEvent): any; }
export interface LocationChangeListener { (e: LocationChangeEvent): any; }

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {PlatformLocation, UrlChangeListener} from '@angular/common';
import {LocationChangeListener, PlatformLocation} from '@angular/common';
import {Injectable} from '@angular/core';
import {getDOM} from '../../dom/dom_adapter';
@ -45,11 +45,11 @@ export class BrowserPlatformLocation extends PlatformLocation {
getBaseHrefFromDOM(): string { return getDOM().getBaseHref(); }
onPopState(fn: UrlChangeListener): void {
onPopState(fn: LocationChangeListener): void {
getDOM().getGlobalEventTarget('window').addEventListener('popstate', fn, false);
}
onHashChange(fn: UrlChangeListener): void {
onHashChange(fn: LocationChangeListener): void {
getDOM().getGlobalEventTarget('window').addEventListener('hashchange', fn, false);
}

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {UrlChangeListener} from '@angular/common';
import {LocationChangeListener} from '@angular/common';
import {Injectable} from '@angular/core';
import {BrowserPlatformLocation} from '../../browser/location/browser_platform_location';
@ -28,9 +28,9 @@ export class MessageBasedPlatformLocation {
private _platformLocation: BrowserPlatformLocation, bus: MessageBus,
private _serializer: Serializer) {
this._platformLocation.onPopState(
<UrlChangeListener>FunctionWrapper.bind(this._sendUrlChangeEvent, this));
<LocationChangeListener>FunctionWrapper.bind(this._sendUrlChangeEvent, this));
this._platformLocation.onHashChange(
<UrlChangeListener>FunctionWrapper.bind(this._sendUrlChangeEvent, this));
<LocationChangeListener>FunctionWrapper.bind(this._sendUrlChangeEvent, this));
this._broker = this._brokerFactory.createMessageBroker(ROUTER_CHANNEL);
this._channelSink = bus.to(ROUTER_CHANNEL);
}

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {PlatformLocation, UrlChangeListener} from '@angular/common';
import {LocationChangeListener, PlatformLocation} from '@angular/common';
import {BaseException, Injectable} from '@angular/core';
import {EventEmitter} from '../../facade/async';
@ -75,9 +75,9 @@ export class WebWorkerPlatformLocation extends PlatformLocation {
'Attempt to get base href from DOM from WebWorker. You must either provide a value for the APP_BASE_HREF token through DI or use the hash location strategy.');
}
onPopState(fn: UrlChangeListener): void { this._popStateListeners.push(fn); }
onPopState(fn: LocationChangeListener): void { this._popStateListeners.push(fn); }
onHashChange(fn: UrlChangeListener): void { this._hashChangeListeners.push(fn); }
onHashChange(fn: LocationChangeListener): void { this._hashChangeListeners.push(fn); }
get pathname(): string {
if (this._location === null) {

View File

@ -33,7 +33,7 @@ export declare class HashLocationStrategy extends LocationStrategy {
back(): void;
forward(): void;
getBaseHref(): string;
onPopState(fn: UrlChangeListener): void;
onPopState(fn: LocationChangeListener): void;
path(includeHash?: boolean): string;
prepareExternalUrl(internal: string): string;
pushState(state: any, title: string, path: string, queryParams: string): void;
@ -77,12 +77,22 @@ export declare class Location {
static stripTrailingSlash(url: string): string;
}
/** @experimental */
export interface LocationChangeEvent {
type: string;
}
/** @experimental */
export interface LocationChangeListener {
(e: LocationChangeEvent): any;
}
/** @stable */
export declare abstract class LocationStrategy {
abstract back(): void;
abstract forward(): void;
abstract getBaseHref(): string;
abstract onPopState(fn: UrlChangeListener): void;
abstract onPopState(fn: LocationChangeListener): void;
abstract path(includeHash?: boolean): string;
abstract prepareExternalUrl(internal: string): string;
abstract pushState(state: any, title: string, url: string, queryParams: string): void;
@ -177,7 +187,7 @@ export declare class PathLocationStrategy extends LocationStrategy {
back(): void;
forward(): void;
getBaseHref(): string;
onPopState(fn: UrlChangeListener): void;
onPopState(fn: LocationChangeListener): void;
path(includeHash?: boolean): string;
prepareExternalUrl(internal: string): string;
pushState(state: any, title: string, url: string, queryParams: string): void;
@ -197,8 +207,8 @@ export declare abstract class PlatformLocation {
abstract back(): void;
abstract forward(): void;
abstract getBaseHrefFromDOM(): string;
abstract onHashChange(fn: UrlChangeListener): void;
abstract onPopState(fn: UrlChangeListener): void;
abstract onHashChange(fn: LocationChangeListener): void;
abstract onPopState(fn: LocationChangeListener): void;
abstract pushState(state: any, title: string, url: string): void;
abstract replaceState(state: any, title: string, url: string): void;
}
@ -212,13 +222,3 @@ export declare class SlicePipe implements PipeTransform {
export declare class UpperCasePipe implements PipeTransform {
transform(value: string): string;
}
/** @experimental */
export interface UrlChangeEvent {
type: string;
}
/** @experimental */
export interface UrlChangeListener {
(e: UrlChangeEvent): any;
}

View File

@ -21,8 +21,8 @@ export declare class BrowserPlatformLocation extends PlatformLocation {
back(): void;
forward(): void;
getBaseHrefFromDOM(): string;
onHashChange(fn: UrlChangeListener): void;
onPopState(fn: UrlChangeListener): void;
onHashChange(fn: LocationChangeListener): void;
onPopState(fn: LocationChangeListener): void;
pushState(state: any, title: string, url: string): void;
replaceState(state: any, title: string, url: string): void;
}