ngx-quicklink
Advanced tools
Comparing version 0.0.10 to 0.0.11
@@ -1,1 +0,1 @@ | ||
(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("@angular/core"),require("@angular/router"),require("rxjs")):typeof define==="function"&&define.amd?define(["exports","@angular/core","@angular/router","rxjs"],factory):(global=global||self,factory(global.ngxql={},global.core,global.router,global.rxjs))})(this,function(exports,core,router,rxjs){"use strict";var __decorate=undefined&&undefined.__decorate||function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)if(d=decorators[i])r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r;return c>3&&r&&Object.defineProperty(target,key,r),r};var __metadata=undefined&&undefined.__metadata||function(k,v){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(k,v)};var PrefetchRegistry=function(){function PrefetchRegistry(router$$1){this.router=router$$1;this.trees=[]}PrefetchRegistry.prototype.add=function(tree){this.trees.push(tree)};PrefetchRegistry.prototype.shouldPrefetch=function(url){var tree=this.router.parseUrl(url);return this.trees.some(function(child){return containsTree(child,tree)})};PrefetchRegistry=__decorate([core.Injectable(),__metadata("design:paramtypes",[router.Router])],PrefetchRegistry);return PrefetchRegistry}();function containsQueryParams(container,containee){return Object.keys(containee).length<=Object.keys(container).length&&Object.keys(containee).every(function(key){return containee[key]===container[key]})}function containsTree(container,containee){return containsQueryParams(container.queryParams,containee.queryParams)&&containsSegmentGroup(container.root,containee.root)}function containsSegmentGroup(container,containee){return containsSegmentGroupHelper(container,containee,containee.segments)}function containsSegmentGroupHelper(container,containee,containeePaths){if(container.segments.length>containeePaths.length){var current=container.segments.slice(0,containeePaths.length);if(!equalPath(current,containeePaths))return false;if(containee.hasChildren())return false;return true}else if(container.segments.length===containeePaths.length){if(!equalPath(container.segments,containeePaths))return false;for(var c in containee.children){if(!container.children[c])return false;if(!containsSegmentGroup(container.children[c],containee.children[c]))return false}return true}else{var current=containeePaths.slice(0,container.segments.length);var next=containeePaths.slice(container.segments.length);if(!equalPath(container.segments,current))return false;if(!container.children[router.PRIMARY_OUTLET])return false;return containsSegmentGroupHelper(container.children[router.PRIMARY_OUTLET],containee,next)}}function equalPath(as,bs){if(as.length!==bs.length)return false;return as.every(function(a,i){return a.path===bs[i].path})}var __decorate$1=undefined&&undefined.__decorate||function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)if(d=decorators[i])r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r;return c>3&&r&&Object.defineProperty(target,key,r),r};var __metadata$1=undefined&&undefined.__metadata||function(k,v){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(k,v)};var ɵ0=function(cb){var start=Date.now();return setTimeout(function(){cb({didTimeout:false,timeRemaining:function(){return Math.max(0,50-(Date.now()-start))}})},1)},ɵ1=function(){};var requestIdleCallback=typeof window!=="undefined"?window.requestIdleCallback||ɵ0:ɵ1;var ɵ2=function(){};var cancelIdleCallback=typeof window!=="undefined"?window.cancelIdleCallback||clearTimeout:ɵ2;var observerSupported=function(){return typeof window!=="undefined"?!!window.IntersectionObserver:false};var LinkHandler=new core.InjectionToken("LinkHandler");var ObservableLinkHandler=function(){function ObservableLinkHandler(loader,queue){var _this=this;this.loader=loader;this.queue=queue;this.registerBuffer=[];this.unregisterBuffer=[];this.elementLink=new Map;this.observer=observerSupported()?new IntersectionObserver(function(entries){entries.forEach(function(entry){if(entry.isIntersecting){var link=entry.target;_this.queue.add(_this.elementLink.get(link).urlTree);_this.observer.unobserve(link);requestIdleCallback(function(){_this.loader.preload().subscribe(function(){return void 0})})}})}):null}ObservableLinkHandler.prototype.register=function(el){var _this=this;this.elementLink.set(el.element,el);cancelIdleCallback(this.registerIdle);this.registerBuffer.push(el.element);this.registerIdle=requestIdleCallback(function(){_this.registerBuffer.forEach(function(e){return _this.observer.observe(e)});_this.registerBuffer=[]})};ObservableLinkHandler.prototype.unregister=function(el){var _this=this;this.elementLink.delete(el.element);cancelIdleCallback(this.unregisterIdle);this.unregisterBuffer.push(el.element);this.unregisterIdle=requestIdleCallback(function(){_this.unregisterBuffer.forEach(function(e){return _this.observer.unobserve(e)});_this.unregisterBuffer=[]})};ObservableLinkHandler.prototype.supported=function(){return observerSupported()};ObservableLinkHandler=__decorate$1([core.Injectable(),__metadata$1("design:paramtypes",[router.RouterPreloader,PrefetchRegistry])],ObservableLinkHandler);return ObservableLinkHandler}();var PreloadLinkHandler=function(){function PreloadLinkHandler(loader,queue){this.loader=loader;this.queue=queue}PreloadLinkHandler.prototype.register=function(el){var _this=this;this.queue.add(el.urlTree);requestIdleCallback(function(){return _this.loader.preload().subscribe(function(){return void 0})})};PreloadLinkHandler.prototype.unregister=function(_){};PreloadLinkHandler.prototype.supported=function(){return true};PreloadLinkHandler=__decorate$1([core.Injectable(),__metadata$1("design:paramtypes",[router.RouterPreloader,PrefetchRegistry])],PreloadLinkHandler);return PreloadLinkHandler}();var __decorate$2=undefined&&undefined.__decorate||function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)if(d=decorators[i])r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r;return c>3&&r&&Object.defineProperty(target,key,r),r};var __metadata$2=undefined&&undefined.__metadata||function(k,v){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(k,v)};var __param=undefined&&undefined.__param||function(paramIndex,decorator){return function(target,key){decorator(target,key,paramIndex)}};var LinkDirective=function(){function LinkDirective(linkHandlers,el,link,linkWithHref){this.linkHandlers=linkHandlers;this.el=el;this.linkHandler=this.linkHandlers.filter(function(h){return h.supported()}).shift();this.rl=link||linkWithHref}LinkDirective.prototype.ngOnInit=function(){this.linkHandler.register(this)};LinkDirective.prototype.ngOnChanges=function(){this.linkHandler.unregister(this);this.linkHandler.register(this)};LinkDirective.prototype.ngOnDestroy=function(){this.linkHandler.unregister(this)};Object.defineProperty(LinkDirective.prototype,"element",{get:function(){return this.el.nativeElement},enumerable:true,configurable:true});Object.defineProperty(LinkDirective.prototype,"urlTree",{get:function(){return this.rl.urlTree},enumerable:true,configurable:true});__decorate$2([core.Input(),__metadata$2("design:type",String)],LinkDirective.prototype,"routerLink",void 0);LinkDirective=__decorate$2([core.Directive({selector:"[routerLink]"}),__param(0,core.Inject(LinkHandler)),__param(2,core.Optional()),__param(3,core.Optional()),__metadata$2("design:paramtypes",[Array,core.ElementRef,router.RouterLink,router.RouterLinkWithHref])],LinkDirective);return LinkDirective}();var __decorate$3=undefined&&undefined.__decorate||function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)if(d=decorators[i])r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r;return c>3&&r&&Object.defineProperty(target,key,r),r};var __metadata$3=undefined&&undefined.__metadata||function(k,v){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(k,v)};var QuicklinkStrategy=function(){function QuicklinkStrategy(queue,router$$1){this.queue=queue;this.router=router$$1;this.loading=new Set}QuicklinkStrategy.prototype.preload=function(route,load){if(this.loading.has(route)){return rxjs.EMPTY}var conn=typeof window!=="undefined"?navigator.connection:undefined;if(conn){if((conn.effectiveType||"").includes("2g")||conn.saveData)return rxjs.EMPTY}if(route.data&&route.data.preload===false){return rxjs.EMPTY}var fullPath=findPath(this.router.config,route);if(this.queue.shouldPrefetch(fullPath)){this.loading.add(route);return load()}return rxjs.EMPTY};QuicklinkStrategy=__decorate$3([core.Injectable(),__metadata$3("design:paramtypes",[PrefetchRegistry,router.Router])],QuicklinkStrategy);return QuicklinkStrategy}();var findPath=function(config,route){config=config.slice();var parent=new Map;var visited=new Set;var _loop_1=function(){var el=config.shift();visited.add(el);if(el===route)return"break";var children=el.children||[];var current_1=el._loadedConfig;if(current_1&¤t_1.routes){children=children.concat(current_1.routes)}children.forEach(function(r){if(visited.has(r))return;parent.set(r,el);config.push(r)})};while(config.length){var state_1=_loop_1();if(state_1==="break")break}var segments=[];var current=route;while(current){segments.unshift(current.path);current=parent.get(current)}return"/"+segments.join("/")};var __decorate$4=undefined&&undefined.__decorate||function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)if(d=decorators[i])r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r;return c>3&&r&&Object.defineProperty(target,key,r),r};var QuicklinkModule=function(){function QuicklinkModule(){}QuicklinkModule=__decorate$4([core.NgModule({declarations:[LinkDirective],providers:[{provide:LinkHandler,useClass:ObservableLinkHandler,multi:true},{provide:LinkHandler,useClass:PreloadLinkHandler,multi:true},PrefetchRegistry,QuicklinkStrategy],exports:[LinkDirective]})],QuicklinkModule);return QuicklinkModule}();exports.QuicklinkModule=QuicklinkModule;exports.QuicklinkStrategy=QuicklinkStrategy;Object.defineProperty(exports,"__esModule",{value:true})}); | ||
(function(e,t){typeof exports==="object"&&typeof module!=="undefined"?t(exports,require("@angular/core"),require("@angular/router"),require("rxjs")):typeof define==="function"&&define.amd?define(["exports","@angular/core","@angular/router","rxjs"],t):(e=e||self,t(e.ngxql={},e.core,e.router,e.rxjs))})(this,function(e,t,u,i){"use strict";var r=undefined&&undefined.__decorate||function(e,t,r,n){var i=arguments.length,o=i<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,r):n,u;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")o=Reflect.decorate(e,t,r,n);else for(var f=e.length-1;f>=0;f--)if(u=e[f])o=(i<3?u(o):i>3?u(t,r,o):u(t,r))||o;return i>3&&o&&Object.defineProperty(t,r,o),o};var n=undefined&&undefined.__metadata||function(e,t){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(e,t)};var o=function(){function e(e){this.router=e;this.trees=[]}e.prototype.add=function(e){this.trees.push(e)};e.prototype.shouldPrefetch=function(e){var t=this.router.parseUrl(e);return this.trees.some(a.bind(null,t))};e=r([t.Injectable(),n("design:paramtypes",[u.Router])],e);return e}();function f(t,r){return Object.keys(r).length<=Object.keys(t).length&&Object.keys(r).every(function(e){return r[e]===t[e]})}function a(e,t){return f(t.queryParams,e.queryParams)&&s(t.root,e.root,e.root.segments)}function s(e,t,r){if(e.segments.length>r.length){var n=e.segments.slice(0,r.length);if(!c(n,r))return false;if(t.hasChildren())return false;return true}else if(e.segments.length===r.length){if(!c(e.segments,r))return false;for(var i in t.children){if(!e.children[i])return false;if(!s(e.children[i],t.children[i],t.children[i].segments))return false}return true}else{var n=r.slice(0,e.segments.length);var o=r.slice(e.segments.length);if(!c(e.segments,n))return false;if(!e.children[u.PRIMARY_OUTLET])return false;return s(e.children[u.PRIMARY_OUTLET],t,o)}}function c(e,r){if(e.length!==r.length)return false;return e.every(function(e,t){return e.path===r[t].path||e.path.startsWith(":")||r[t].path.startsWith(":")})}var l=undefined&&undefined.__decorate||function(e,t,r,n){var i=arguments.length,o=i<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,r):n,u;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")o=Reflect.decorate(e,t,r,n);else for(var f=e.length-1;f>=0;f--)if(u=e[f])o=(i<3?u(o):i>3?u(t,r,o):u(t,r))||o;return i>3&&o&&Object.defineProperty(t,r,o),o};var d=undefined&&undefined.__metadata||function(e,t){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(e,t)};var p=function(e){var t=Date.now();return setTimeout(function(){e({didTimeout:false,timeRemaining:function(){return Math.max(0,50-(Date.now()-t))}})},1)},h=function(){};var g=typeof window!=="undefined"?window.requestIdleCallback||p:h;var v=function(){};var y=typeof window!=="undefined"?window.cancelIdleCallback||clearTimeout:v;var b=function(){return typeof window!=="undefined"?!!window.IntersectionObserver:false};var m=new t.InjectionToken("LinkHandler");var R=function(){function e(e,t){var r=this;this.loader=e;this.queue=t;this.registerBuffer=[];this.unregisterBuffer=[];this.elementLink=new Map;this.observer=b()?new IntersectionObserver(function(e){e.forEach(function(e){if(e.isIntersecting){var t=e.target;r.queue.add(r.elementLink.get(t).urlTree);r.observer.unobserve(t);g(function(){r.loader.preload().subscribe(function(){return void 0})})}})}):null}e.prototype.register=function(e){var t=this;this.elementLink.set(e.element,e);y(this.registerIdle);this.registerBuffer.push(e.element);this.registerIdle=g(function(){t.registerBuffer.forEach(function(e){return t.observer.observe(e)});t.registerBuffer=[]})};e.prototype.unregister=function(e){var t=this;this.elementLink.delete(e.element);y(this.unregisterIdle);this.unregisterBuffer.push(e.element);this.unregisterIdle=g(function(){t.unregisterBuffer.forEach(function(e){return t.observer.unobserve(e)});t.unregisterBuffer=[]})};e.prototype.supported=function(){return b()};e=l([t.Injectable(),d("design:paramtypes",[u.RouterPreloader,o])],e);return e}();var j=function(){function e(e,t){this.loader=e;this.queue=t}e.prototype.register=function(e){var t=this;this.queue.add(e.urlTree);g(function(){return t.loader.preload().subscribe(function(){return void 0})})};e.prototype.unregister=function(e){};e.prototype.supported=function(){return true};e=l([t.Injectable(),d("design:paramtypes",[u.RouterPreloader,o])],e);return e}();var O=undefined&&undefined.__decorate||function(e,t,r,n){var i=arguments.length,o=i<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,r):n,u;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")o=Reflect.decorate(e,t,r,n);else for(var f=e.length-1;f>=0;f--)if(u=e[f])o=(i<3?u(o):i>3?u(t,r,o):u(t,r))||o;return i>3&&o&&Object.defineProperty(t,r,o),o};var k=undefined&&undefined.__metadata||function(e,t){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(e,t)};var w=undefined&&undefined.__param||function(r,n){return function(e,t){n(e,t,r)}};var P=function(){function e(e,t,r,n){this.linkHandlers=e;this.el=t;this.linkHandler=this.linkHandlers.filter(function(e){return e.supported()}).shift();this.rl=r||n}e.prototype.ngOnInit=function(){this.linkHandler.register(this)};e.prototype.ngOnChanges=function(){this.linkHandler.unregister(this);this.linkHandler.register(this)};e.prototype.ngOnDestroy=function(){this.linkHandler.unregister(this)};Object.defineProperty(e.prototype,"element",{get:function(){return this.el.nativeElement},enumerable:true,configurable:true});Object.defineProperty(e.prototype,"urlTree",{get:function(){return this.rl.urlTree},enumerable:true,configurable:true});O([t.Input(),k("design:type",String)],e.prototype,"routerLink",void 0);e=O([t.Directive({selector:"[routerLink]"}),w(0,t.Inject(m)),w(2,t.Optional()),w(3,t.Optional()),k("design:paramtypes",[Array,t.ElementRef,u.RouterLink,u.RouterLinkWithHref])],e);return e}();var _=undefined&&undefined.__decorate||function(e,t,r,n){var i=arguments.length,o=i<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,r):n,u;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")o=Reflect.decorate(e,t,r,n);else for(var f=e.length-1;f>=0;f--)if(u=e[f])o=(i<3?u(o):i>3?u(t,r,o):u(t,r))||o;return i>3&&o&&Object.defineProperty(t,r,o),o};var I=undefined&&undefined.__metadata||function(e,t){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(e,t)};var T=function(){function e(e,t){this.queue=e;this.router=t;this.loading=new Set}e.prototype.preload=function(e,t){if(this.loading.has(e)){return i.EMPTY}var r=typeof window!=="undefined"?navigator.connection:undefined;if(r){if((r.effectiveType||"").includes("2g")||r.saveData)return i.EMPTY}if(e.data&&e.data.preload===false){return i.EMPTY}var n=q(this.router.config,e);if(this.queue.shouldPrefetch(n)){this.loading.add(e);return t()}return i.EMPTY};e=_([t.Injectable(),I("design:paramtypes",[o,u.Router])],e);return e}();var q=function(n,i){n=n.slice();var o=new Map;var u=new Set;var e=function(){var t=n.shift();u.add(t);if(t===i)return"break";var e=t.children||[];var r=t._loadedConfig;if(r&&r.routes){e=e.concat(r.routes)}e.forEach(function(e){if(u.has(e))return;o.set(e,t);n.push(e)})};while(n.length){var t=e();if(t==="break")break}var r=[];var f=i;while(f){r.unshift(f.path);f=o.get(f)}return"/"+r.join("/")};var E=undefined&&undefined.__decorate||function(e,t,r,n){var i=arguments.length,o=i<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,r):n,u;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")o=Reflect.decorate(e,t,r,n);else for(var f=e.length-1;f>=0;f--)if(u=e[f])o=(i<3?u(o):i>3?u(t,r,o):u(t,r))||o;return i>3&&o&&Object.defineProperty(t,r,o),o};var M=function(){function e(){}e=E([t.NgModule({declarations:[P],providers:[{provide:m,useClass:R,multi:true},{provide:m,useClass:j,multi:true},o,T],exports:[P]})],e);return e}();e.QuicklinkModule=M;e.QuicklinkStrategy=T;Object.defineProperty(e,"__esModule",{value:true})}); |
{ | ||
"name": "ngx-quicklink", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"description": "Quicklink for Angular", | ||
@@ -19,3 +19,3 @@ "keywords": [ | ||
"scripts": { | ||
"release": "rm -rf dist && ngc -p tsconfig.json && cp package.json dist/src && cp README.md dist/src && rollup dist/src/index.js --file dist/src/index.umd.js --format umd --name ngxql && uglifyjs dist/src/index.umd.js -o dist/src/index.umd.js", | ||
"release": "rm -rf dist && ngc -p tsconfig.json && cp package.json dist/src && cp README.md dist/src && rollup dist/src/index.js --file dist/src/index.umd.js --format umd --name ngxql && uglifyjs dist/src/index.umd.js -m -o dist/src/index.umd.js", | ||
"start": "nodemon -e ts --watch src --exec \"npm run release\"", | ||
@@ -22,0 +22,0 @@ "format": "prettier --single-quote --write src/*.ts" |
@@ -22,3 +22,3 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var tree = this.router.parseUrl(url); | ||
return this.trees.some(function (child) { return containsTree(child, tree); }); | ||
return this.trees.some(containsTree.bind(null, tree)); | ||
}; | ||
@@ -37,10 +37,7 @@ PrefetchRegistry = __decorate([ | ||
} | ||
function containsTree(container, containee) { | ||
function containsTree(containee, container) { | ||
return (containsQueryParams(container.queryParams, containee.queryParams) && | ||
containsSegmentGroup(container.root, containee.root)); | ||
containsSegmentGroup(container.root, containee.root, containee.root.segments)); | ||
} | ||
function containsSegmentGroup(container, containee) { | ||
return containsSegmentGroupHelper(container, containee, containee.segments); | ||
} | ||
function containsSegmentGroupHelper(container, containee, containeePaths) { | ||
function containsSegmentGroup(container, containee, containeePaths) { | ||
if (container.segments.length > containeePaths.length) { | ||
@@ -60,3 +57,3 @@ var current = container.segments.slice(0, containeePaths.length); | ||
return false; | ||
if (!containsSegmentGroup(container.children[c], containee.children[c])) | ||
if (!containsSegmentGroup(container.children[c], containee.children[c], containee.children[c].segments)) | ||
return false; | ||
@@ -73,3 +70,3 @@ } | ||
return false; | ||
return containsSegmentGroupHelper(container.children[PRIMARY_OUTLET], containee, next); | ||
return containsSegmentGroup(container.children[PRIMARY_OUTLET], containee, next); | ||
} | ||
@@ -80,4 +77,4 @@ } | ||
return false; | ||
return as.every(function (a, i) { return a.path === bs[i].path; }); | ||
return as.every(function (a, i) { return a.path === bs[i].path || a.path.startsWith(':') || bs[i].path.startsWith(':'); }); | ||
} | ||
//# sourceMappingURL=prefetch-registry.service.js.map |
@@ -31,3 +31,3 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
} | ||
// Allow preload blacklisting | ||
// Prevent from preloading | ||
if (route.data && route.data.preload === false) { | ||
@@ -37,3 +37,2 @@ return EMPTY; | ||
var fullPath = findPath(this.router.config, route); | ||
// TODO(mgechev): make sure it works for parameterized routes | ||
if (this.queue.shouldPrefetch(fullPath)) { | ||
@@ -40,0 +39,0 @@ this.loading.add(route); |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":4,"metadata":{"QuicklinkStrategy":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":5,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./prefetch-registry.service","name":"PrefetchRegistry","line":9,"character":29},{"__symbolic":"reference","module":"@angular/router","name":"Router","line":9,"character":63}]}],"preload":[{"__symbolic":"method"}]}},"ɵ0":{"__symbolic":"error","message":"Lambda not supported","line":36,"character":17}}}] | ||
[{"__symbolic":"module","version":4,"metadata":{"QuicklinkStrategy":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":5,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./prefetch-registry.service","name":"PrefetchRegistry","line":9,"character":29},{"__symbolic":"reference","module":"@angular/router","name":"Router","line":9,"character":63}]}],"preload":[{"__symbolic":"method"}]}},"ɵ0":{"__symbolic":"error","message":"Lambda not supported","line":35,"character":17}}}] |
@@ -34,3 +34,3 @@ <p align="center"> | ||
// ... | ||
import {QuicklinkModule, QuicklinkStrategy} from 'ngx-quicklink'; | ||
import { QuicklinkModule, QuicklinkStrategy } from 'ngx-quicklink'; | ||
@@ -42,9 +42,24 @@ @NgModule({ | ||
QuicklinkModule, | ||
RouterModule.forRoot(routes, {preloadingStrategy: QuicklinkStrategy}), | ||
RouterModule.forRoot(routes, { preloadingStrategy: QuicklinkStrategy }), | ||
], | ||
bootstrap: [...] | ||
}) | ||
export class AppModule { } | ||
export class AppModule {} | ||
``` | ||
If you want to add a route in the ignore list so that `ngx-quicklink` will not preload it use the `data` property: | ||
```ts | ||
export const routes: Routes = [ | ||
{ | ||
path: 'contact', | ||
loadChildren: './contact/contact.module#ContactModule', | ||
data: { | ||
preload: false | ||
} | ||
} | ||
]; | ||
``` | ||
**Note that to make the module available in lazy-loaded modules as well you need to import it in a shared module and export it.** Look at [this commit](https://github.com/mgechev/angular-realworld-example-app-qucklink/commit/33ea101c7d84bb5ca086f107148bbc958659f83f) to see how `ngx-quicklink` is integrated in the [angular-realworld-example-app](https://github.com/gothinkster/angular-realworld-example-app). | ||
@@ -54,3 +69,3 @@ | ||
``` | ||
```shell | ||
cd ngx-quicklink && npm i && npm run release | ||
@@ -92,2 +107,1 @@ cd example && npm i && ng serve | ||
MIT | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
104
65360
475