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:
parent
8a2324f86a
commit
1f5a5895e5
|
@ -12,7 +12,7 @@ import {isPresent} from '../facade/lang';
|
||||||
|
|
||||||
import {Location} from './location';
|
import {Location} from './location';
|
||||||
import {APP_BASE_HREF, LocationStrategy} from './location_strategy';
|
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.onPopState(fn);
|
||||||
this._platformLocation.onHashChange(fn);
|
this._platformLocation.onHashChange(fn);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {OpaqueToken} from '@angular/core';
|
import {OpaqueToken} from '@angular/core';
|
||||||
import {UrlChangeListener} from './platform_location';
|
import {LocationChangeListener} from './platform_location';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `LocationStrategy` is responsible for representing and reading route state
|
* `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 replaceState(state: any, title: string, url: string, queryParams: string): void;
|
||||||
abstract forward(): void;
|
abstract forward(): void;
|
||||||
abstract back(): void;
|
abstract back(): void;
|
||||||
abstract onPopState(fn: UrlChangeListener): void;
|
abstract onPopState(fn: LocationChangeListener): void;
|
||||||
abstract getBaseHref(): string;
|
abstract getBaseHref(): string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,8 @@ import {isBlank} from '../facade/lang';
|
||||||
|
|
||||||
import {Location} from './location';
|
import {Location} from './location';
|
||||||
import {APP_BASE_HREF, LocationStrategy} from './location_strategy';
|
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;
|
this._baseHref = href;
|
||||||
}
|
}
|
||||||
|
|
||||||
onPopState(fn: UrlChangeListener): void {
|
onPopState(fn: LocationChangeListener): void {
|
||||||
this._platformLocation.onPopState(fn);
|
this._platformLocation.onPopState(fn);
|
||||||
this._platformLocation.onHashChange(fn);
|
this._platformLocation.onHashChange(fn);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,8 @@
|
||||||
*/
|
*/
|
||||||
export abstract class PlatformLocation {
|
export abstract class PlatformLocation {
|
||||||
abstract getBaseHrefFromDOM(): string;
|
abstract getBaseHrefFromDOM(): string;
|
||||||
abstract onPopState(fn: UrlChangeListener): void;
|
abstract onPopState(fn: LocationChangeListener): void;
|
||||||
abstract onHashChange(fn: UrlChangeListener): void;
|
abstract onHashChange(fn: LocationChangeListener): void;
|
||||||
|
|
||||||
get pathname(): string { return null; }
|
get pathname(): string { return null; }
|
||||||
get search(): string { return null; }
|
get search(): string { return null; }
|
||||||
|
@ -55,9 +55,9 @@ export abstract class PlatformLocation {
|
||||||
*
|
*
|
||||||
* @experimental
|
* @experimental
|
||||||
*/
|
*/
|
||||||
export interface UrlChangeEvent { type: string; }
|
export interface LocationChangeEvent { type: string; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @experimental
|
* @experimental
|
||||||
*/
|
*/
|
||||||
export interface UrlChangeListener { (e: UrlChangeEvent): any; }
|
export interface LocationChangeListener { (e: LocationChangeEvent): any; }
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* 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 {Injectable} from '@angular/core';
|
||||||
|
|
||||||
import {getDOM} from '../../dom/dom_adapter';
|
import {getDOM} from '../../dom/dom_adapter';
|
||||||
|
@ -45,11 +45,11 @@ export class BrowserPlatformLocation extends PlatformLocation {
|
||||||
|
|
||||||
getBaseHrefFromDOM(): string { return getDOM().getBaseHref(); }
|
getBaseHrefFromDOM(): string { return getDOM().getBaseHref(); }
|
||||||
|
|
||||||
onPopState(fn: UrlChangeListener): void {
|
onPopState(fn: LocationChangeListener): void {
|
||||||
getDOM().getGlobalEventTarget('window').addEventListener('popstate', fn, false);
|
getDOM().getGlobalEventTarget('window').addEventListener('popstate', fn, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
onHashChange(fn: UrlChangeListener): void {
|
onHashChange(fn: LocationChangeListener): void {
|
||||||
getDOM().getGlobalEventTarget('window').addEventListener('hashchange', fn, false);
|
getDOM().getGlobalEventTarget('window').addEventListener('hashchange', fn, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* 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 {Injectable} from '@angular/core';
|
||||||
|
|
||||||
import {BrowserPlatformLocation} from '../../browser/location/browser_platform_location';
|
import {BrowserPlatformLocation} from '../../browser/location/browser_platform_location';
|
||||||
|
@ -28,9 +28,9 @@ export class MessageBasedPlatformLocation {
|
||||||
private _platformLocation: BrowserPlatformLocation, bus: MessageBus,
|
private _platformLocation: BrowserPlatformLocation, bus: MessageBus,
|
||||||
private _serializer: Serializer) {
|
private _serializer: Serializer) {
|
||||||
this._platformLocation.onPopState(
|
this._platformLocation.onPopState(
|
||||||
<UrlChangeListener>FunctionWrapper.bind(this._sendUrlChangeEvent, this));
|
<LocationChangeListener>FunctionWrapper.bind(this._sendUrlChangeEvent, this));
|
||||||
this._platformLocation.onHashChange(
|
this._platformLocation.onHashChange(
|
||||||
<UrlChangeListener>FunctionWrapper.bind(this._sendUrlChangeEvent, this));
|
<LocationChangeListener>FunctionWrapper.bind(this._sendUrlChangeEvent, this));
|
||||||
this._broker = this._brokerFactory.createMessageBroker(ROUTER_CHANNEL);
|
this._broker = this._brokerFactory.createMessageBroker(ROUTER_CHANNEL);
|
||||||
this._channelSink = bus.to(ROUTER_CHANNEL);
|
this._channelSink = bus.to(ROUTER_CHANNEL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* 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 {BaseException, Injectable} from '@angular/core';
|
||||||
|
|
||||||
import {EventEmitter} from '../../facade/async';
|
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.');
|
'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 {
|
get pathname(): string {
|
||||||
if (this._location === null) {
|
if (this._location === null) {
|
||||||
|
|
|
@ -33,7 +33,7 @@ export declare class HashLocationStrategy extends LocationStrategy {
|
||||||
back(): void;
|
back(): void;
|
||||||
forward(): void;
|
forward(): void;
|
||||||
getBaseHref(): string;
|
getBaseHref(): string;
|
||||||
onPopState(fn: UrlChangeListener): void;
|
onPopState(fn: LocationChangeListener): void;
|
||||||
path(includeHash?: boolean): string;
|
path(includeHash?: boolean): string;
|
||||||
prepareExternalUrl(internal: string): string;
|
prepareExternalUrl(internal: string): string;
|
||||||
pushState(state: any, title: string, path: string, queryParams: string): void;
|
pushState(state: any, title: string, path: string, queryParams: string): void;
|
||||||
|
@ -77,12 +77,22 @@ export declare class Location {
|
||||||
static stripTrailingSlash(url: string): string;
|
static stripTrailingSlash(url: string): string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @experimental */
|
||||||
|
export interface LocationChangeEvent {
|
||||||
|
type: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @experimental */
|
||||||
|
export interface LocationChangeListener {
|
||||||
|
(e: LocationChangeEvent): any;
|
||||||
|
}
|
||||||
|
|
||||||
/** @stable */
|
/** @stable */
|
||||||
export declare abstract class LocationStrategy {
|
export declare abstract class LocationStrategy {
|
||||||
abstract back(): void;
|
abstract back(): void;
|
||||||
abstract forward(): void;
|
abstract forward(): void;
|
||||||
abstract getBaseHref(): string;
|
abstract getBaseHref(): string;
|
||||||
abstract onPopState(fn: UrlChangeListener): void;
|
abstract onPopState(fn: LocationChangeListener): void;
|
||||||
abstract path(includeHash?: boolean): string;
|
abstract path(includeHash?: boolean): string;
|
||||||
abstract prepareExternalUrl(internal: string): string;
|
abstract prepareExternalUrl(internal: string): string;
|
||||||
abstract pushState(state: any, title: string, url: string, queryParams: string): void;
|
abstract pushState(state: any, title: string, url: string, queryParams: string): void;
|
||||||
|
@ -177,7 +187,7 @@ export declare class PathLocationStrategy extends LocationStrategy {
|
||||||
back(): void;
|
back(): void;
|
||||||
forward(): void;
|
forward(): void;
|
||||||
getBaseHref(): string;
|
getBaseHref(): string;
|
||||||
onPopState(fn: UrlChangeListener): void;
|
onPopState(fn: LocationChangeListener): void;
|
||||||
path(includeHash?: boolean): string;
|
path(includeHash?: boolean): string;
|
||||||
prepareExternalUrl(internal: string): string;
|
prepareExternalUrl(internal: string): string;
|
||||||
pushState(state: any, title: string, url: string, queryParams: string): void;
|
pushState(state: any, title: string, url: string, queryParams: string): void;
|
||||||
|
@ -197,8 +207,8 @@ export declare abstract class PlatformLocation {
|
||||||
abstract back(): void;
|
abstract back(): void;
|
||||||
abstract forward(): void;
|
abstract forward(): void;
|
||||||
abstract getBaseHrefFromDOM(): string;
|
abstract getBaseHrefFromDOM(): string;
|
||||||
abstract onHashChange(fn: UrlChangeListener): void;
|
abstract onHashChange(fn: LocationChangeListener): void;
|
||||||
abstract onPopState(fn: UrlChangeListener): void;
|
abstract onPopState(fn: LocationChangeListener): void;
|
||||||
abstract pushState(state: any, title: string, url: string): void;
|
abstract pushState(state: any, title: string, url: string): void;
|
||||||
abstract replaceState(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 {
|
export declare class UpperCasePipe implements PipeTransform {
|
||||||
transform(value: string): string;
|
transform(value: string): string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @experimental */
|
|
||||||
export interface UrlChangeEvent {
|
|
||||||
type: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @experimental */
|
|
||||||
export interface UrlChangeListener {
|
|
||||||
(e: UrlChangeEvent): any;
|
|
||||||
}
|
|
||||||
|
|
|
@ -21,8 +21,8 @@ export declare class BrowserPlatformLocation extends PlatformLocation {
|
||||||
back(): void;
|
back(): void;
|
||||||
forward(): void;
|
forward(): void;
|
||||||
getBaseHrefFromDOM(): string;
|
getBaseHrefFromDOM(): string;
|
||||||
onHashChange(fn: UrlChangeListener): void;
|
onHashChange(fn: LocationChangeListener): void;
|
||||||
onPopState(fn: UrlChangeListener): void;
|
onPopState(fn: LocationChangeListener): void;
|
||||||
pushState(state: any, title: string, url: string): void;
|
pushState(state: any, title: string, url: string): void;
|
||||||
replaceState(state: any, title: string, url: string): void;
|
replaceState(state: any, title: string, url: string): void;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue