ngx-suspense
Version:
This library is an experimetnal implementation of React Suspense for Angular.
645 lines (610 loc) • 31.4 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('@angular/animations'), require('@angular/platform-browser/animations'), require('@angular/common')) :
typeof define === 'function' && define.amd ? define('ngx-suspense', ['exports', '@angular/core', 'rxjs', 'rxjs/operators', '@angular/animations', '@angular/platform-browser/animations', '@angular/common'], factory) :
(global = global || self, factory(global['ngx-suspense'] = {}, global.ng.core, global.rxjs, global.rxjs.operators, global.ng.animations, global.ng.platformBrowser.animations, global.ng.common));
}(this, (function (exports, core, rxjs, operators, animations, animations$1, common) { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
function __decorate(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;
}
function __param(paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
}
function __metadata(metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
}
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
function __exportStar(m, exports) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
function __values(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
}
function __spread() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
}
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
function __await(v) {
return this instanceof __await ? (this.v = v, this) : new __await(v);
}
function __asyncGenerator(thisArg, _arguments, generator) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
function fulfill(value) { resume("next", value); }
function reject(value) { resume("throw", value); }
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
}
function __asyncDelegator(o) {
var i, p;
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
}
function __asyncValues(o) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
}
function __makeTemplateObject(cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
function __importStar(mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result.default = mod;
return result;
}
function __importDefault(mod) {
return (mod && mod.__esModule) ? mod : { default: mod };
}
function __classPrivateFieldGet(receiver, privateMap) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to get private field on non-instance");
}
return privateMap.get(receiver);
}
function __classPrivateFieldSet(receiver, privateMap, value) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to set private field on non-instance");
}
privateMap.set(receiver, value);
return value;
}
var LOADING_DEFUALT_CONFIG = {
busyMinDurationMs: 0,
busyDelayMs: 0,
};
var LOADING_CONFIG_TOKEN = new core.InjectionToken("LOADING_CONFIG_TOKEN");
var NgxSuspenseService = /** @class */ (function () {
function NgxSuspenseService(userConfig) {
if (userConfig === void 0) { userConfig = LOADING_DEFUALT_CONFIG; }
this.userConfig = userConfig;
this.loadingSubject = new rxjs.BehaviorSubject(false);
this.loading$ = this.loadingSubject.asObservable();
this.taskStartSubject = new rxjs.Subject();
this.taskStart$ = this.taskStartSubject.asObservable();
this.taskEndSubject = new rxjs.Subject();
this.taskEnd$ = this.taskEndSubject.asObservable();
}
NgxSuspenseService.prototype.ngOnDestroy = function () {
if (this.sub && typeof this.sub.unsubscribe === "function") {
this.sub.unsubscribe();
}
};
Object.defineProperty(NgxSuspenseService.prototype, "busyTimer", {
set: function (_a) {
var busyDelayMs = _a.busyDelayMs, busyMinDurationMs = _a.busyMinDurationMs;
if (typeof busyDelayMs === "number") {
this.userConfig.busyDelayMs = busyDelayMs;
}
if (typeof busyMinDurationMs === "number") {
this.userConfig.busyMinDurationMs = busyMinDurationMs;
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgxSuspenseService.prototype, "config", {
get: function () {
return this.userConfig;
},
enumerable: true,
configurable: true
});
NgxSuspenseService.prototype.show = function () {
this.loadingSubject.next(true);
};
NgxSuspenseService.prototype.hide = function () {
this.loadingSubject.next(false);
};
NgxSuspenseService.prototype.controller = function () {
var _this = this;
this.busyMinDurationTimer = rxjs.timer(this.config.busyMinDurationMs + this.config.busyDelayMs);
this.busyDelayTimer = rxjs.timer(this.config.busyDelayMs);
var busyDelayTimerStart = this.taskStart$.pipe(operators.switchMap(function () { return _this.busyDelayTimer; }));
var busyDelayTimerEnd = busyDelayTimerStart.pipe(operators.takeUntil(this.taskEnd$));
var emitOnTaskEnd = this.taskEnd$.pipe(operators.mapTo(1));
var emitOnDelayTimerEnd = busyDelayTimerEnd.pipe(operators.mapTo(-1));
var emitOnMinDurationEnd = this.busyMinDurationTimer.pipe(operators.mapTo(-1));
// Start loading skeleton
var raceBetweenTaskAndDelay = rxjs.combineLatest([
emitOnTaskEnd.pipe(operators.startWith(null)),
emitOnDelayTimerEnd.pipe(operators.startWith(null)),
]).pipe(operators.skip(1));
var taskEndBeforeDelay = raceBetweenTaskAndDelay.pipe(operators.filter(function (_a) {
var _b = __read(_a, 2), taskEndFirst = _b[0], timerEndFirst = _b[1];
return taskEndFirst === 1 && timerEndFirst === null;
}));
var shouldNotShowSpinner = taskEndBeforeDelay.pipe(operators.mapTo(false));
var taskEndAfterTimeout = raceBetweenTaskAndDelay.pipe(operators.filter(function (_a) {
var _b = __read(_a, 2), taskEndFirst = _b[0], timerEndFirst = _b[1];
return taskEndFirst === null && timerEndFirst === -1;
}));
var shouldShowSpinner = taskEndAfterTimeout.pipe(operators.mapTo(true));
var showSpinner = shouldShowSpinner.pipe(operators.tap(function () {
_this.show();
}));
// hide loading skeleton
var raceBetweenTaskAndMinDuration = rxjs.combineLatest([
emitOnTaskEnd.pipe(operators.startWith(null)),
emitOnMinDurationEnd.pipe(operators.startWith(null)),
]).pipe(operators.skip(1));
var hideSpinnerUntilMinDurationEnd = raceBetweenTaskAndMinDuration.pipe(operators.filter(function (_a) {
var _b = __read(_a, 2), taskEndFirst = _b[0], timerEndFirst = _b[1];
return taskEndFirst === 1 && timerEndFirst === null;
}));
var hideSpinnerAfterTimerAndTaskEnd = raceBetweenTaskAndMinDuration.pipe(operators.filter(function (_a) {
var _b = __read(_a, 2), taskEndFirst = _b[0], timerEndFirst = _b[1];
return taskEndFirst === 1 && timerEndFirst === -1;
}));
var hideSpinner = rxjs.merge(
// case 1: should not show spinner at all
shouldNotShowSpinner,
// case 2: task end, but wait until min duration timer ends
rxjs.combineLatest([hideSpinnerUntilMinDurationEnd, emitOnMinDurationEnd]),
// case 3: task takes a long time, wait unitl its end
hideSpinnerAfterTimerAndTaskEnd).pipe(operators.tap(function () {
_this.hide();
}));
return showSpinner.pipe(operators.takeUntil(hideSpinner));
};
NgxSuspenseService.prototype.showLoadingStatus = function () {
var _this = this;
if (this.sub && typeof this.sub.unsubscribe === "function") {
this.sub.unsubscribe();
}
this.sub = this.controller().subscribe();
return function (source) {
return new rxjs.Observable(function (subscriber) {
var emitOnObsEnd = source.pipe(operators.tap(function () {
_this.taskEndSubject.next();
}));
var sub = rxjs.of(null)
.pipe(operators.tap(function () {
_this.taskStartSubject.next();
}), operators.concatMap(function () { return emitOnObsEnd; }), operators.shareReplay(1))
.subscribe(subscriber);
return function () {
sub.unsubscribe();
};
});
};
};
NgxSuspenseService.prototype.showingFor = function (obs$) {
var _this = this;
if (this.sub && typeof this.sub.unsubscribe === "function") {
this.sub.unsubscribe();
}
this.sub = this.controller().subscribe();
var emitOnObsEnd = obs$.pipe(operators.tap(function () {
_this.taskEndSubject.next();
}));
return rxjs.of(null).pipe(operators.tap(function () {
_this.taskStartSubject.next();
}), operators.concatMap(function () { return emitOnObsEnd; }), operators.shareReplay(1));
};
NgxSuspenseService.ctorParameters = function () { return [
{ type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [LOADING_CONFIG_TOKEN,] }] }
]; };
NgxSuspenseService = __decorate([
core.Injectable(),
__param(0, core.Optional()),
__param(0, core.Inject(LOADING_CONFIG_TOKEN))
], NgxSuspenseService);
return NgxSuspenseService;
}());
var NgxSuspenseComponent = /** @class */ (function () {
function NgxSuspenseComponent(loadingService) {
this.loadingService = loadingService;
this.ariaLabel = "Loading...";
this.isVisible = false;
}
NgxSuspenseComponent.prototype.ngOnInit = function () {
this.service = this.getService();
this.loading$ = this.service.loading$;
};
NgxSuspenseComponent.prototype.getService = function () {
return this.bind || this.loadingService;
};
NgxSuspenseComponent.prototype.show = function () {
this.service.show();
this.isVisible = true;
};
NgxSuspenseComponent.prototype.hide = function () {
this.service.hide();
this.isVisible = false;
};
NgxSuspenseComponent.ctorParameters = function () { return [
{ type: NgxSuspenseService }
]; };
__decorate([
core.Input()
], NgxSuspenseComponent.prototype, "fallback", void 0);
__decorate([
core.Input()
], NgxSuspenseComponent.prototype, "ariaLabel", void 0);
__decorate([
core.Input()
], NgxSuspenseComponent.prototype, "bind", void 0);
__decorate([
core.Input()
], NgxSuspenseComponent.prototype, "isVisible", void 0);
NgxSuspenseComponent = __decorate([
core.Component({
selector: "Suspense",
template: "<ng-template #content>\n <!-- animation doesn't work with ng-template, ng-content or ng-container, have to add extra div for workaround-->\n <div [@fadeIn]>\n <ng-content></ng-content>\n </div>\n</ng-template>\n\n<div\n *ngIf=\"(loading$ | async) || isVisible; else content\"\n role=\"alert\"\n aria-busy=\"true\"\n aria-hidden=\"false\"\n [attr.aria-label]=\"ariaLabel\"\n>\n <ng-container *ngTemplateOutlet=\"fallback\"></ng-container>\n</div>\n",
animations: [
animations.trigger("fadeIn", [
animations.transition(":enter", [
animations.style({ opacity: 0 }),
animations.animate("300ms ease-in", animations.style({
opacity: 1,
})),
]),
]),
],
styles: ["\n :host {\n display: block;\n }\n "]
})
], NgxSuspenseComponent);
return NgxSuspenseComponent;
}());
var NgxSuspenseListComponent = /** @class */ (function () {
function NgxSuspenseListComponent() {
this.revealOrder = "*";
this.subs = [];
this.allBroadcasters = [];
this.allListeners = [];
this.hasParentControlSubject = new rxjs.BehaviorSubject(undefined);
this.parentControl$ = this.hasParentControlSubject.asObservable();
}
NgxSuspenseListComponent_1 = NgxSuspenseListComponent;
NgxSuspenseListComponent.prototype.ngOnInit = function () {
this.parentControl$
.pipe(operators.tap(function (val) {
console.log("release", val);
}))
.subscribe();
};
NgxSuspenseListComponent.prototype.ngAfterContentInit = function () {
var _this = this;
this.allBroadcasters = this.skeletons.map(function (s) { return s.loading$; });
this.allListeners = this.skeletons.map(function (s) { return _this.hideSkeletonListener(s); });
this.revealOrderOperator(this.revealOrder);
};
NgxSuspenseListComponent.prototype.ngOnChanges = function (changes) {
if (changes.revealOrder) {
this.revealOrderOperator(changes.revealOrder.currentValue);
}
};
NgxSuspenseListComponent.prototype.ngOnDestroy = function () {
if (this.subs.length) {
this.subs.forEach(function (sub) { return sub.unsubscribe(); });
this.subs.length = 0;
}
};
NgxSuspenseListComponent.prototype.reload = function (order) {
this.revealOrderOperator(order || this.revealOrder);
};
NgxSuspenseListComponent.prototype.show = function () { };
NgxSuspenseListComponent.prototype.hide = function () { };
NgxSuspenseListComponent.prototype.revealOrderOperator = function (order) {
if (this.allBroadcasters.length === 0 || this.allListeners.length === 0) {
return;
}
if (this.subs.length) {
this.subs.forEach(function (sub) { return sub.unsubscribe(); });
this.subs.length = 0;
}
switch (order) {
case "together": {
var sub = this.togetherOperator(this.allBroadcasters)(this.allListeners);
this.subs.push(sub);
break;
}
case "forwards": {
var subs = this.domOrderOperator(this.allBroadcasters)(this.allListeners);
this.subs = subs;
break;
}
case "backwards": {
var broadcasters = __spread(this.allBroadcasters).reverse();
var listeners = __spread(this.allListeners).reverse();
var subs = this.domOrderOperator(broadcasters)(listeners);
this.subs = subs;
break;
}
default:
// nothing should happen
}
};
NgxSuspenseListComponent.prototype.hideSkeletonListener = function (skeleton) {
return function () {
skeleton.hide();
};
};
NgxSuspenseListComponent.prototype.showSkeletonListener = function (skeleton) {
return function () {
skeleton.show();
};
};
NgxSuspenseListComponent.prototype.togetherOperator = function (broadcasters) {
var _this = this;
this.skeletons.forEach(function (s) { return _this.showSkeletonListener(s)(); });
return function (listeners) {
return rxjs.combineLatest(__spread(broadcasters))
.pipe(
// skip default
operators.skip(1),
// keep tracking previous value
operators.pairwise(), operators.filter(function (_a) {
var _b = __read(_a, 2), ary1 = _b[0], ary2 = _b[1];
// any loading state is ture
var cond1 = ary1.some(function (b) { return b; });
// all loading state is false
var cond2 = !ary2.some(function (b) { return b; });
// pass only when prev loading state is ture, current is false
return cond1 && cond2;
}))
.subscribe(function () {
listeners.forEach(function (hide) { return hide(); });
});
};
};
NgxSuspenseListComponent.prototype.domOrderOperator = function (broadcasters) {
var _this = this;
this.skeletons.forEach(function (s) { return _this.showSkeletonListener(s)(); });
return function (listeners) {
var subs = [];
var checks = __spread(new Array(broadcasters.length)).fill(null);
broadcasters.forEach(function (boradcaster, index) {
subs.push(boradcaster
.pipe(
// skip default
operators.skip(1),
// keep tracking previous value
operators.pairwise(), operators.filter(function (_a) {
var _b = __read(_a, 2), b1 = _b[0], b2 = _b[1];
// pass only when prev loading state is ture, current is false
return b1 && !b2;
}))
.subscribe(function () {
var e_1, _a;
checks[index] = true;
var indexesToFlush = _this.getFlushIndexes(checks);
try {
for (var indexesToFlush_1 = __values(indexesToFlush), indexesToFlush_1_1 = indexesToFlush_1.next(); !indexesToFlush_1_1.done; indexesToFlush_1_1 = indexesToFlush_1.next()) {
var i = indexesToFlush_1_1.value;
listeners[i]();
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (indexesToFlush_1_1 && !indexesToFlush_1_1.done && (_a = indexesToFlush_1.return)) _a.call(indexesToFlush_1);
}
finally { if (e_1) throw e_1.error; }
}
}));
});
return subs;
};
};
NgxSuspenseListComponent.prototype.getFlushIndexes = function (checks) {
var indexesToFlush = [];
for (var i = 0; i < checks.length; i++) {
if (indexesToFlush.indexOf(i) > -1) {
continue;
}
var check = checks[i];
if (check !== null) {
indexesToFlush.push(i);
}
else {
break;
}
}
return indexesToFlush;
};
var NgxSuspenseListComponent_1;
__decorate([
core.Input()
], NgxSuspenseListComponent.prototype, "revealOrder", void 0);
__decorate([
core.ContentChildren(NgxSuspenseComponent)
], NgxSuspenseListComponent.prototype, "skeletons", void 0);
__decorate([
core.ContentChildren(NgxSuspenseListComponent_1)
], NgxSuspenseListComponent.prototype, "list", void 0);
NgxSuspenseListComponent = NgxSuspenseListComponent_1 = __decorate([
core.Component({
selector: "SuspenseList",
template: "<ng-content></ng-content>\n",
exportAs: "list"
})
], NgxSuspenseListComponent);
return NgxSuspenseListComponent;
}());
var ɵ0 = LOADING_DEFUALT_CONFIG;
var NgxSuspenseModule = /** @class */ (function () {
function NgxSuspenseModule() {
}
NgxSuspenseModule_1 = NgxSuspenseModule;
NgxSuspenseModule.forRoot = function (config) {
return {
ngModule: NgxSuspenseModule_1,
providers: [
{
provide: LOADING_CONFIG_TOKEN,
useValue: __assign(__assign({}, LOADING_DEFUALT_CONFIG), config),
},
],
};
};
var NgxSuspenseModule_1;
NgxSuspenseModule = NgxSuspenseModule_1 = __decorate([
core.NgModule({
declarations: [NgxSuspenseListComponent, NgxSuspenseComponent],
imports: [animations$1.BrowserAnimationsModule, common.CommonModule],
providers: [
{
provide: LOADING_CONFIG_TOKEN,
useValue: ɵ0,
},
],
schemas: [core.CUSTOM_ELEMENTS_SCHEMA],
exports: [NgxSuspenseComponent, NgxSuspenseListComponent],
})
], NgxSuspenseModule);
return NgxSuspenseModule;
}());
exports.LOADING_CONFIG_TOKEN = LOADING_CONFIG_TOKEN;
exports.LOADING_DEFUALT_CONFIG = LOADING_DEFUALT_CONFIG;
exports.NgxSuspenseComponent = NgxSuspenseComponent;
exports.NgxSuspenseListComponent = NgxSuspenseListComponent;
exports.NgxSuspenseModule = NgxSuspenseModule;
exports.NgxSuspenseService = NgxSuspenseService;
exports.ɵ0 = ɵ0;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=ngx-suspense.umd.js.map