1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.BaseLocationServices = void 0;
|
4 | var common_1 = require("../common");
|
5 | var utils_1 = require("./utils");
|
6 |
|
7 | var BaseLocationServices = (function () {
|
8 | function BaseLocationServices(router, fireAfterUpdate) {
|
9 | var _this = this;
|
10 | this.fireAfterUpdate = fireAfterUpdate;
|
11 | this._listeners = [];
|
12 | this._listener = function (evt) { return _this._listeners.forEach(function (cb) { return cb(evt); }); };
|
13 | this.hash = function () { return utils_1.parseUrl(_this._get()).hash; };
|
14 | this.path = function () { return utils_1.parseUrl(_this._get()).path; };
|
15 | this.search = function () { return utils_1.getParams(utils_1.parseUrl(_this._get()).search); };
|
16 | this._location = common_1.root.location;
|
17 | this._history = common_1.root.history;
|
18 | }
|
19 | BaseLocationServices.prototype.url = function (url, replace) {
|
20 | if (replace === void 0) { replace = true; }
|
21 | if (common_1.isDefined(url) && url !== this._get()) {
|
22 | this._set(null, null, url, replace);
|
23 | if (this.fireAfterUpdate) {
|
24 | this._listeners.forEach(function (cb) { return cb({ url: url }); });
|
25 | }
|
26 | }
|
27 | return utils_1.buildUrl(this);
|
28 | };
|
29 | BaseLocationServices.prototype.onChange = function (cb) {
|
30 | var _this = this;
|
31 | this._listeners.push(cb);
|
32 | return function () { return common_1.removeFrom(_this._listeners, cb); };
|
33 | };
|
34 | BaseLocationServices.prototype.dispose = function (router) {
|
35 | common_1.deregAll(this._listeners);
|
36 | };
|
37 | return BaseLocationServices;
|
38 | }());
|
39 | exports.BaseLocationServices = BaseLocationServices;
|
40 |
|
\ | No newline at end of file |