Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ngx-error-boundary

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-error-boundary - npm Package Compare versions

Comparing version 0.0.1-alpha.0 to 0.0.1

CHANGELOG.md

189

bundles/ngx-error-boundary.umd.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core')) :
typeof define === 'function' && define.amd ? define('ngx-error-boundary', ['exports', '@angular/core'], factory) :
(global = global || self, factory(global['ngx-error-boundary'] = {}, global.ng.core));
}(this, (function (exports, core) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('@angular/common')) :
typeof define === 'function' && define.amd ? define('ngx-error-boundary', ['exports', '@angular/core', 'rxjs', 'rxjs/operators', '@angular/common'], factory) :
(global = global || self, factory(global['ngx-error-boundary'] = {}, global.ng.core, global.rxjs, global.rxjs.operators, global.ng.common));
}(this, (function (exports, core, rxjs, operators, common) { 'use strict';

@@ -223,8 +223,70 @@ /*! *****************************************************************************

function NgxErrorBoundaryService() {
var _this = this;
this.errorStore = {};
this.keyStore = {};
this.errorsSubject = new rxjs.BehaviorSubject({});
this.keySubject = new rxjs.BehaviorSubject({});
this.retryStatusSubjet = new rxjs.BehaviorSubject("end");
this.retryStatus$ = this.retryStatusSubjet.asObservable();
this.retryClickSubject = new rxjs.Subject();
this.retryClick$ = this.retryClickSubject.asObservable().pipe(operators.tap(function () {
_this.retryStatusSubjet.next("start");
}));
this.errors$ = this.errorsSubject.asObservable().pipe(operators.filter(function (message) { return !!message; }));
this.keys$ = this.keySubject.asObservable().pipe(operators.filter(function (key) { return !!key; }));
}
NgxErrorBoundaryService.ɵprov = core.ɵɵdefineInjectable({ factory: function NgxErrorBoundaryService_Factory() { return new NgxErrorBoundaryService(); }, token: NgxErrorBoundaryService, providedIn: "root" });
NgxErrorBoundaryService.prototype.showErrors = function (errors, key) {
var _a, _b;
if (key === void 0) { key = "_$ngx_error_boundary_global_error$_"; }
this.errorStore = Object.assign({}, this.errorStore, (_a = {}, _a[key] = errors, _a));
this.keyStore = Object.assign({}, this.keyStore, (_b = {}, _b[key] = true, _b));
this.errorsSubject.next(this.errorStore);
this.keySubject.next(this.keyStore);
};
NgxErrorBoundaryService.prototype.handleExpection = function (errorOption) {
var _this = this;
if (errorOption === void 0) { errorOption = {}; }
var message = errorOption.message, key = errorOption.key;
return function (obs$) {
return new rxjs.Observable(function (subscriber) {
var sub = obs$
.pipe(operators.catchError(function (err) {
// Catch error every time it emits
_this.retryStatusSubjet.next("end");
var readableMessage = message || JSON.stringify(err);
_this.showErrors(readableMessage, key);
return rxjs.throwError(err);
}),
//retry max times
operators.retryWhen(function (err) {
return err.pipe(operators.exhaustMap(function () { return _this.retryClick$; }), operators.delay(10));
}), operators.tap(function (x) {
// Success
_this.dismiss(key);
}))
.subscribe(subscriber);
return function () {
sub.unsubscribe();
};
});
};
};
NgxErrorBoundaryService.prototype.dismiss = function (key) {
if (!key) {
// Dismis all
this.errorStore = {};
this.keyStore = {};
this.errorsSubject.next({});
this.keySubject.next({});
}
delete this.errorStore[key];
delete this.keyStore[key];
this.errorsSubject.next(this.errorStore);
this.keySubject.next(this.keyStore);
};
NgxErrorBoundaryService.prototype.doRetry = function () {
this.retryClickSubject.next();
};
NgxErrorBoundaryService = __decorate([
core.Injectable({
providedIn: 'root'
})
core.Injectable()
], NgxErrorBoundaryService);

@@ -235,10 +297,50 @@ return NgxErrorBoundaryService;

var NgxErrorBoundaryComponent = /** @class */ (function () {
function NgxErrorBoundaryComponent() {
function NgxErrorBoundaryComponent(errorService) {
this.errorService = errorService;
this.key = "_$ngx_error_boundary_global_error$_";
}
NgxErrorBoundaryComponent.prototype.ngOnInit = function () {
var _this = this;
this.errors$ = rxjs.combineLatest([
this.errorService.errors$,
this.errorService.keys$,
]).pipe(operators.map(function (_a) {
var _b = __read(_a, 2), errors = _b[0], keys = _b[1];
return _this.zip(errors, keys);
}));
this.isRetrying$ = this.errorService.retryStatus$.pipe(operators.map(function (status) {
return status !== "end";
}));
};
NgxErrorBoundaryComponent.prototype.ngOnDestroy = function () {
this.sub.unsubscribe();
};
NgxErrorBoundaryComponent.prototype.zip = function (errors, keys) {
return Object.keys(keys).reduce(function (acc, curr) {
var _a;
return __assign(__assign({}, acc), (_a = {}, _a[curr] = errors[curr], _a));
}, {});
};
NgxErrorBoundaryComponent.prototype.getContext = function (error, key) {
return {
$implicit: {
message: error,
key: key,
},
retry$: this.isRetrying$,
};
};
NgxErrorBoundaryComponent.ctorParameters = function () { return [
{ type: NgxErrorBoundaryService }
]; };
__decorate([
core.Input()
], NgxErrorBoundaryComponent.prototype, "fallback", void 0);
__decorate([
core.Input()
], NgxErrorBoundaryComponent.prototype, "key", void 0);
NgxErrorBoundaryComponent = __decorate([
core.Component({
selector: 'lib-ngx-error-boundary',
template: "\n <p>\n ngx-error-boundary works!\n </p>\n "
selector: "ErrorBoundary",
template: "<ng-container *ngIf=\"errors$ | async as errors; else content\">\n <ng-container *ngIf=\"errors[key] as error; else content\">\n <ng-container\n [ngTemplateOutlet]=\"fallback\"\n [ngTemplateOutletContext]=\"getContext(error, key)\"\n >\n </ng-container>\n </ng-container>\n</ng-container>\n\n<ng-template #content>\n <ng-content></ng-content>\n</ng-template>\n"
})

@@ -249,2 +351,50 @@ ], NgxErrorBoundaryComponent);

var NgxErrorRetryDirective = /** @class */ (function () {
function NgxErrorRetryDirective(errorService) {
this.errorService = errorService;
}
NgxErrorRetryDirective.prototype.onClick = function () {
this.errorService.doRetry();
};
NgxErrorRetryDirective.prototype.ngOnInit = function () { };
NgxErrorRetryDirective.ctorParameters = function () { return [
{ type: NgxErrorBoundaryService }
]; };
__decorate([
core.HostListener("click")
], NgxErrorRetryDirective.prototype, "onClick", null);
NgxErrorRetryDirective = __decorate([
core.Directive({
selector: "[errorRetry]",
exportAs: "retry",
})
], NgxErrorRetryDirective);
return NgxErrorRetryDirective;
}());
var NgxErrorDismissDirective = /** @class */ (function () {
function NgxErrorDismissDirective(errorService) {
this.errorService = errorService;
}
NgxErrorDismissDirective.prototype.onClick = function () {
this.errorService.dismiss(this.errorDismiss);
};
NgxErrorDismissDirective.ctorParameters = function () { return [
{ type: NgxErrorBoundaryService }
]; };
__decorate([
core.Input()
], NgxErrorDismissDirective.prototype, "errorDismiss", void 0);
__decorate([
core.HostListener("click")
], NgxErrorDismissDirective.prototype, "onClick", null);
NgxErrorDismissDirective = __decorate([
core.Directive({
selector: "[errorDismiss]",
exportAs: "dismiss",
})
], NgxErrorDismissDirective);
return NgxErrorDismissDirective;
}());
var NgxErrorBoundaryModule = /** @class */ (function () {

@@ -255,5 +405,14 @@ function NgxErrorBoundaryModule() {

core.NgModule({
declarations: [NgxErrorBoundaryComponent],
imports: [],
exports: [NgxErrorBoundaryComponent]
declarations: [
NgxErrorBoundaryComponent,
NgxErrorRetryDirective,
NgxErrorDismissDirective,
],
imports: [common.CommonModule],
exports: [
NgxErrorBoundaryComponent,
NgxErrorRetryDirective,
NgxErrorDismissDirective,
],
schemas: [core.CUSTOM_ELEMENTS_SCHEMA],
})

@@ -267,2 +426,4 @@ ], NgxErrorBoundaryModule);

exports.NgxErrorBoundaryService = NgxErrorBoundaryService;
exports.NgxErrorDismissDirective = NgxErrorDismissDirective;
exports.NgxErrorRetryDirective = NgxErrorRetryDirective;

@@ -269,0 +430,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

4

bundles/ngx-error-boundary.umd.min.js

@@ -1,2 +0,2 @@

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@angular/core")):"function"==typeof define&&define.amd?define("ngx-error-boundary",["exports","@angular/core"],r):r((e=e||self)["ngx-error-boundary"]={},e.ng.core)}(this,(function(e,r){"use strict";
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("rxjs"),require("rxjs/operators"),require("@angular/common")):"function"==typeof define&&define.amd?define("ngx-error-boundary",["exports","@angular/core","rxjs","rxjs/operators","@angular/common"],e):e((r=r||self)["ngx-error-boundary"]={},r.ng.core,r.rxjs,r.rxjs.operators,r.ng.common)}(this,(function(r,e,t,n,o){"use strict";
/*! *****************************************************************************

@@ -15,3 +15,3 @@ Copyright (c) Microsoft Corporation. All rights reserved.

and limitations under the License.
***************************************************************************** */function n(e,r,n,o){var t,u=arguments.length,c=u<3?r:null===o?o=Object.getOwnPropertyDescriptor(r,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,r,n,o);else for(var f=e.length-1;f>=0;f--)(t=e[f])&&(c=(u<3?t(c):u>3?t(r,n,c):t(r,n))||c);return u>3&&c&&Object.defineProperty(r,n,c),c}var o=function(){function e(){}return e.ɵprov=r.ɵɵdefineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e=n([r.Injectable({providedIn:"root"})],e)}(),t=function(){function e(){}return e.prototype.ngOnInit=function(){},e=n([r.Component({selector:"lib-ngx-error-boundary",template:"\n <p>\n ngx-error-boundary works!\n </p>\n "})],e)}(),u=function(){function e(){}return e=n([r.NgModule({declarations:[t],imports:[],exports:[t]})],e)}();e.NgxErrorBoundaryComponent=t,e.NgxErrorBoundaryModule=u,e.NgxErrorBoundaryService=o,Object.defineProperty(e,"__esModule",{value:!0})}));
***************************************************************************** */var i=function(){return(i=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++)for(var o in e=arguments[t])Object.prototype.hasOwnProperty.call(e,o)&&(r[o]=e[o]);return r}).apply(this,arguments)};function s(r,e,t,n){var o,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,t):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s}function c(r,e){var t="function"==typeof Symbol&&r[Symbol.iterator];if(!t)return r;var n,o,i=t.call(r),s=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(r){o={error:r}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return s}var u=function(){function r(){var r=this;this.errorStore={},this.keyStore={},this.errorsSubject=new t.BehaviorSubject({}),this.keySubject=new t.BehaviorSubject({}),this.retryStatusSubjet=new t.BehaviorSubject("end"),this.retryStatus$=this.retryStatusSubjet.asObservable(),this.retryClickSubject=new t.Subject,this.retryClick$=this.retryClickSubject.asObservable().pipe(n.tap((function(){r.retryStatusSubjet.next("start")}))),this.errors$=this.errorsSubject.asObservable().pipe(n.filter((function(r){return!!r}))),this.keys$=this.keySubject.asObservable().pipe(n.filter((function(r){return!!r})))}return r.prototype.showErrors=function(r,e){var t,n;void 0===e&&(e="_$ngx_error_boundary_global_error$_"),this.errorStore=Object.assign({},this.errorStore,((t={})[e]=r,t)),this.keyStore=Object.assign({},this.keyStore,((n={})[e]=!0,n)),this.errorsSubject.next(this.errorStore),this.keySubject.next(this.keyStore)},r.prototype.handleExpection=function(r){var e=this;void 0===r&&(r={});var o=r.message,i=r.key;return function(r){return new t.Observable((function(s){var c=r.pipe(n.catchError((function(r){e.retryStatusSubjet.next("end");var n=o||JSON.stringify(r);return e.showErrors(n,i),t.throwError(r)})),n.retryWhen((function(r){return r.pipe(n.exhaustMap((function(){return e.retryClick$})),n.delay(10))})),n.tap((function(r){e.dismiss(i)}))).subscribe(s);return function(){c.unsubscribe()}}))}},r.prototype.dismiss=function(r){r||(this.errorStore={},this.keyStore={},this.errorsSubject.next({}),this.keySubject.next({})),delete this.errorStore[r],delete this.keyStore[r],this.errorsSubject.next(this.errorStore),this.keySubject.next(this.keyStore)},r.prototype.doRetry=function(){this.retryClickSubject.next()},r=s([e.Injectable()],r)}(),a=function(){function r(r){this.errorService=r,this.key="_$ngx_error_boundary_global_error$_"}return r.prototype.ngOnInit=function(){var r=this;this.errors$=t.combineLatest([this.errorService.errors$,this.errorService.keys$]).pipe(n.map((function(e){var t=c(e,2),n=t[0],o=t[1];return r.zip(n,o)}))),this.isRetrying$=this.errorService.retryStatus$.pipe(n.map((function(r){return"end"!==r})))},r.prototype.ngOnDestroy=function(){this.sub.unsubscribe()},r.prototype.zip=function(r,e){return Object.keys(e).reduce((function(e,t){var n;return i(i({},e),((n={})[t]=r[t],n))}),{})},r.prototype.getContext=function(r,e){return{$implicit:{message:r,key:e},retry$:this.isRetrying$}},r.ctorParameters=function(){return[{type:u}]},s([e.Input()],r.prototype,"fallback",void 0),s([e.Input()],r.prototype,"key",void 0),r=s([e.Component({selector:"ErrorBoundary",template:'<ng-container *ngIf="errors$ | async as errors; else content">\n <ng-container *ngIf="errors[key] as error; else content">\n <ng-container\n [ngTemplateOutlet]="fallback"\n [ngTemplateOutletContext]="getContext(error, key)"\n >\n </ng-container>\n </ng-container>\n</ng-container>\n\n<ng-template #content>\n <ng-content></ng-content>\n</ng-template>\n'})],r)}(),p=function(){function r(r){this.errorService=r}return r.prototype.onClick=function(){this.errorService.doRetry()},r.prototype.ngOnInit=function(){},r.ctorParameters=function(){return[{type:u}]},s([e.HostListener("click")],r.prototype,"onClick",null),r=s([e.Directive({selector:"[errorRetry]",exportAs:"retry"})],r)}(),y=function(){function r(r){this.errorService=r}return r.prototype.onClick=function(){this.errorService.dismiss(this.errorDismiss)},r.ctorParameters=function(){return[{type:u}]},s([e.Input()],r.prototype,"errorDismiss",void 0),s([e.HostListener("click")],r.prototype,"onClick",null),r=s([e.Directive({selector:"[errorDismiss]",exportAs:"dismiss"})],r)}(),l=function(){function r(){}return r=s([e.NgModule({declarations:[a,p,y],imports:[o.CommonModule],exports:[a,p,y],schemas:[e.CUSTOM_ELEMENTS_SCHEMA]})],r)}();r.NgxErrorBoundaryComponent=a,r.NgxErrorBoundaryModule=l,r.NgxErrorBoundaryService=u,r.NgxErrorDismissDirective=y,r.NgxErrorRetryDirective=p,Object.defineProperty(r,"__esModule",{value:!0})}));
//# sourceMappingURL=ngx-error-boundary.umd.min.js.map
import { __decorate } from "tslib";
import { Component } from '@angular/core';
import { Component, Input, } from "@angular/core";
import { NgxErrorBoundaryService } from "./ngx-error-boundary.service";
import { combineLatest } from "rxjs";
import { map } from "rxjs/operators";
let NgxErrorBoundaryComponent = class NgxErrorBoundaryComponent {
constructor() { }
constructor(errorService) {
this.errorService = errorService;
this.key = "_$ngx_error_boundary_global_error$_";
}
ngOnInit() {
this.errors$ = combineLatest([
this.errorService.errors$,
this.errorService.keys$,
]).pipe(map(([errors, keys]) => this.zip(errors, keys)));
this.isRetrying$ = this.errorService.retryStatus$.pipe(map((status) => {
return status !== "end";
}));
}
ngOnDestroy() {
this.sub.unsubscribe();
}
zip(errors, keys) {
return Object.keys(keys).reduce((acc, curr) => {
return Object.assign(Object.assign({}, acc), { [curr]: errors[curr] });
}, {});
}
getContext(error, key) {
return {
$implicit: {
message: error,
key,
},
retry$: this.isRetrying$,
};
}
};
NgxErrorBoundaryComponent.ctorParameters = () => [
{ type: NgxErrorBoundaryService }
];
__decorate([
Input()
], NgxErrorBoundaryComponent.prototype, "fallback", void 0);
__decorate([
Input()
], NgxErrorBoundaryComponent.prototype, "key", void 0);
NgxErrorBoundaryComponent = __decorate([
Component({
selector: 'lib-ngx-error-boundary',
template: `
<p>
ngx-error-boundary works!
</p>
`
selector: "ErrorBoundary",
template: "<ng-container *ngIf=\"errors$ | async as errors; else content\">\n <ng-container *ngIf=\"errors[key] as error; else content\">\n <ng-container\n [ngTemplateOutlet]=\"fallback\"\n [ngTemplateOutletContext]=\"getContext(error, key)\"\n >\n </ng-container>\n </ng-container>\n</ng-container>\n\n<ng-template #content>\n <ng-content></ng-content>\n</ng-template>\n"
})
], NgxErrorBoundaryComponent);
export { NgxErrorBoundaryComponent };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmd4LWVyc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KSk7XG5cbiAgICB0aGlzLmlzUmV0cnlpbmckID0gdGhpcy5lcnJvclNlcnZpY2UucmV0cnlTdGF0dXMkLnBpcGUoXG4gICAgICBtYXAoKHN0YXR1cykgPT4ge1xuICAgICAgICByZXR1cm4gc3RhdHVzICE9PSBcImVuZFwiO1xuICAgICAgfSlcbiAgICApO1xuICB9XG5cbiAgbmdPbkRlc3Ryb3koKSB7XG4gICAgdGhpcy5zdWIudW5zdWJzY3JpYmUoKTtcbiAgfVxuXG4gIHppcChlcnJvcnMsIGtleXMpIHtcbiAgICByZXR1cm4gT2JqZWN0LmtleXMoa2V5cykucmVkdWNlKChhY2MsIGN1cnIpID0+IHtcbiAgICAgIHJldHVybiB7XG4gICAgICAgIC4uLmFjYyxcbiAgICAgICAgW2N1cnJdOiBlcnJvcnNbY3Vycl0sXG4gICAgICB9O1xuICAgIH0sIHt9KTtcbiAgfVxuXG4gIGdldENvbnRleHQoZXJyb3IsIGtleSkge1xuICAgIHJldHVybiB7XG4gICAgICAkaW1wbGljaXQ6IHtcbiAgICAgICAgbWVzc2FnZTogZXJyb3IsXG4gICAgICAgIGtleSxcbiAgICAgIH0sXG4gICAgICByZXRyeSQ6IHRoaXMuaXNSZXRyeWluZyQsXG4gICAgfTtcbiAgfVxufVxuIl19
import { __decorate } from "tslib";
import { NgModule } from '@angular/core';
import { NgxErrorBoundaryComponent } from './ngx-error-boundary.component';
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from "@angular/core";
import { NgxErrorBoundaryComponent } from "./ngx-error-boundary.component";
import { NgxErrorRetryDirective } from "./ngx-error-retry.directive";
import { NgxErrorDismissDirective } from "./ngx-error-dismiss.directive";
import { CommonModule } from "@angular/common";
let NgxErrorBoundaryModule = class NgxErrorBoundaryModule {

@@ -8,8 +11,17 @@ };

NgModule({
declarations: [NgxErrorBoundaryComponent],
imports: [],
exports: [NgxErrorBoundaryComponent]
declarations: [
NgxErrorBoundaryComponent,
NgxErrorRetryDirective,
NgxErrorDismissDirective,
],
imports: [CommonModule],
exports: [
NgxErrorBoundaryComponent,
NgxErrorRetryDirective,
NgxErrorDismissDirective,
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
], NgxErrorBoundaryModule);
export { NgxErrorBoundaryModule };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmd4LWVycm9yLWJvdW5kYXJ5Lm1vZHVsZS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL25neC1lcnJvci1ib3VuZGFyeS8iLCJzb3VyY2VzIjpbImxpYi9uZ3gtZXJyb3ItYm91bmRhcnkubW9kdWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBQ3pDLE9BQU8sRUFBRSx5QkFBeUIsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBVTNFLElBQWEsc0JBQXNCLEdBQW5DLE1BQWEsc0JBQXNCO0NBQUksQ0FBQTtBQUExQixzQkFBc0I7SUFObEMsUUFBUSxDQUFDO1FBQ1IsWUFBWSxFQUFFLENBQUMseUJBQXlCLENBQUM7UUFDekMsT0FBTyxFQUFFLEVBQ1I7UUFDRCxPQUFPLEVBQUUsQ0FBQyx5QkFBeUIsQ0FBQztLQUNyQyxDQUFDO0dBQ1csc0JBQXNCLENBQUk7U0FBMUIsc0JBQXNCIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgTmdNb2R1bGUgfSBmcm9tICdAYW5ndWxhci9jb3JlJztcbmltcG9ydCB7IE5neEVycm9yQm91bmRhcnlDb21wb25lbnQgfSBmcm9tICcuL25neC1lcnJvci1ib3VuZGFyeS5jb21wb25lbnQnO1xuXG5cblxuQE5nTW9kdWxlKHtcbiAgZGVjbGFyYXRpb25zOiBbTmd4RXJyb3JCb3VuZGFyeUNvbXBvbmVudF0sXG4gIGltcG9ydHM6IFtcbiAgXSxcbiAgZXhwb3J0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zb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBOZ01vZHVsZSwgQ1VTVE9NX0VMRU1FTlRTX1NDSEVNQSB9IGZyb20gXCJAYW5ndWxhci9jb3JlXCI7XG5pbXBvcnQgeyBOZ3hFcnJvckJvdW5kYXJ5Q29tcG9uZW50IH0gZnJvbSBcIi4vbmd4LWVycm9yLWJvdW5kYXJ5LmNvbXBvbmVudFwiO1xuaW1wb3J0IHsgTmd4RXJyb3JSZXRyeURpcmVjdGl2ZSB9IGZyb20gXCIuL25neC1lcnJvci1yZXRyeS5kaXJlY3RpdmVcIjtcbmltcG9ydCB7IE5neEVycm9yRGlzbWlzc0RpcmVjdGl2ZSB9IGZyb20gXCIuL25neC1lcnJvci1kaXNtaXNzLmRpcmVjdGl2ZVwiO1xuaW1wb3J0IHsgQ29tbW9uTW9kdWxlIH0gZnJvbSBcIkBhbmd1bGFyL2NvbW1vblwiO1xuXG5ATmdNb2R1bGUoe1xuICBkZWNsYXJhdGlvbnM6IFtcbiAgICBOZ3hFcnJvckJvdW5kYXJ5Q29tcG9uZW50LFxuICAgIE5neEVycm9yUmV0cnlEaXJlY3RpdmUsXG4gICAgTmd4RXJyb3JEaXNtaXNzRGlyZWN0aXZlLFxuICBdLFxuICBpbXBvcnRzOiBbQ29tbW9uTW9kdWxlXSxcbiAgZXhwb3J0czogW1xuICAgIE5neEVycm9yQm91bmRhcnlDb21wb25lbnQsXG4gICAgTmd4RXJyb3JSZXRyeURpcmVjdGl2ZSxcbiAgICBOZ3hFcnJvckRpc21pc3NEaXJlY3RpdmUsXG4gIF0sXG4gIHNjaGVtYXM6IFtDVVNUT01fRUxFTUVOVFNfU0NIRU1BXSxcbn0pXG5leHBvcnQgY2xhc3MgTmd4RXJyb3JCb3VuZGFyeU1vZHVsZSB7fVxuIl19
import { __decorate } from "tslib";
import { Injectable } from '@angular/core';
import * as i0 from "@angular/core";
import { Injectable } from "@angular/core";
import { Subject, BehaviorSubject, Observable, throwError, } from "rxjs";
import { filter, retryWhen, delay, catchError, tap, exhaustMap, } from "rxjs/operators";
let NgxErrorBoundaryService = class NgxErrorBoundaryService {
constructor() { }
constructor() {
this.errorStore = {};
this.keyStore = {};
this.errorsSubject = new BehaviorSubject({});
this.keySubject = new BehaviorSubject({});
this.retryStatusSubjet = new BehaviorSubject("end");
this.retryStatus$ = this.retryStatusSubjet.asObservable();
this.retryClickSubject = new Subject();
this.retryClick$ = this.retryClickSubject.asObservable().pipe(tap(() => {
this.retryStatusSubjet.next("start");
}));
this.errors$ = this.errorsSubject.asObservable().pipe(filter((message) => !!message));
this.keys$ = this.keySubject.asObservable().pipe(filter((key) => !!key));
}
showErrors(errors, key = "_$ngx_error_boundary_global_error$_") {
this.errorStore = Object.assign({}, this.errorStore, { [key]: errors });
this.keyStore = Object.assign({}, this.keyStore, { [key]: true });
this.errorsSubject.next(this.errorStore);
this.keySubject.next(this.keyStore);
}
handleExpection(errorOption = {}) {
const { message, key } = errorOption;
return (obs$) => {
return new Observable((subscriber) => {
const sub = obs$
.pipe(catchError((err) => {
// Catch error every time it emits
this.retryStatusSubjet.next("end");
const readableMessage = message || JSON.stringify(err);
this.showErrors(readableMessage, key);
return throwError(err);
}),
//retry max times
retryWhen((err) => err.pipe(exhaustMap(() => this.retryClick$), delay(10))), tap((x) => {
// Success
this.dismiss(key);
}))
.subscribe(subscriber);
return () => {
sub.unsubscribe();
};
});
};
}
dismiss(key) {
if (!key) {
// Dismis all
this.errorStore = {};
this.keyStore = {};
this.errorsSubject.next({});
this.keySubject.next({});
}
delete this.errorStore[key];
delete this.keyStore[key];
this.errorsSubject.next(this.errorStore);
this.keySubject.next(this.keyStore);
}
doRetry() {
this.retryClickSubject.next();
}
};
NgxErrorBoundaryService.ɵprov = i0.ɵɵdefineInjectable({ factory: function NgxErrorBoundaryService_Factory() { return new NgxErrorBoundaryService(); }, token: NgxErrorBoundaryService, providedIn: "root" });
NgxErrorBoundaryService = __decorate([
Injectable({
providedIn: 'root'
})
Injectable()
], NgxErrorBoundaryService);
export { NgxErrorBoundaryService };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmd4LWVycm9yLWJvdW5kYXJ5LnNlcnZpY2UuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9uZ3gtZXJyb3ItYm91bmRhcnkvIiwic291cmNlcyI6WyJsaWIvbmd4LWVycm9yLWJvdW5kYXJ5LnNlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxlQUFlLENBQUM7O0FBSzNDLElBQWEsdUJBQXVCLEdBQXBDLE1BQWEsdUJBQXVCO0lBRWxDLGdCQUFnQixDQUFDO0NBQ2xCLENBQUE7O0FBSFksdUJBQXVCO0lBSG5DLFVBQVUsQ0FBQztRQUNWLFVBQVUsRUFBRSxNQUFNO0tBQ25CLENBQUM7R0FDVyx1QkFBdUIsQ0FHbkM7U0FIWSx1QkFBdUIiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBJbmplY3RhYmxlIH0gZnJvbSAnQGFuZ3VsYXIvY29yZSc7XG5cbkBJbmplY3RhYmxlKHtcbiAgcHJvdmlkZWRJbjogJ3Jvb3QnXG59KVxuZXhwb3J0IGNsYXNzIE5neEVycm9yQm91bmRhcnlTZXJ2aWNlIHtcblxuICBjb25zdHJ1Y3RvcigpIHsgfVxufVxuIl19
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmd4LWVycm9yLWJvdW5kYXJ5LnNlcnZpY2UuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9uZ3gtZXJyb3ItYm91bmRhcnkvIiwic291cmNlcyI6WyJsaWIvbmd4LWVycm9yLWJvdW5kYXJ5LnNlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxlQUFlLENBQUM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zdCByZWFkYWJsZU1lc3NhZ2UgPSBtZXNzYWdlIHx8IEpTT04uc3RyaW5naWZ5KGVycik7XG4gICAgICAgICAgICAgIHRoaXMuc2hvd0Vycm9ycyhyZWFkYWJsZU1lc3NhZ2UsIGtleSk7XG4gICAgICAgICAgICAgIHJldHVybiB0aHJvd0Vycm9yKGVycik7XG4gICAgICAgICAgICB9KSxcbiAgICAgICAgICAgIC8vcmV0cnkgbWF4IHRpbWVzXG4gICAgICAgICAgICByZXRyeVdoZW4oKGVycikgPT5cbiAgICAgICAgICAgICAgZXJyLnBpcGUoXG4gICAgICAgICAgICAgICAgZXhoYXVzdE1hcCgoKSA9PiB0aGlzLnJldHJ5Q2xpY2skKSxcbiAgICAgICAgICAgICAgICBkZWxheSgxMClcbiAgICAgICAgICAgICAgKVxuICAgICAgICAgICAgKSxcbiAgICAgICAgICAgIHRhcCgoeCkgPT4ge1xuICAgICAgICAgICAgICAvLyBTdWNjZXNzXG4gICAgICAgICAgICAgIHRoaXMuZGlzbWlzcyhrZXkpO1xuICAgICAgICAgICAgfSlcbiAgICAgICAgICApXG4gICAgICAgICAgLnN1YnNjcmliZShzdWJzY3JpYmVyKTtcblxuICAgICAgICByZXR1cm4gKCkgPT4ge1xuICAgICAgICAgIHN1Yi51bnN1YnNjcmliZSgpO1xuICAgICAgICB9O1xuICAgICAgfSk7XG4gICAgfTtcbiAgfVxuXG4gIGRpc21pc3Moa2V5Pzogc3RyaW5nKSB7XG4gICAgaWYgKCFrZXkpIHtcbiAgICAgIC8vIERpc21pcyBhbGxcbiAgICAgIHRoaXMuZXJyb3JTdG9yZSA9IHt9O1xuICAgICAgdGhpcy5rZXlTdG9yZSA9IHt9O1xuICAgICAgdGhpcy5lcnJvcnNTdWJqZWN0Lm5leHQoe30pO1xuICAgICAgdGhpcy5rZXlTdWJqZWN0Lm5leHQoe30pO1xuICAgIH1cbiAgICBkZWxldGUgdGhpcy5lcnJvclN0b3JlW2tleV07XG4gICAgZGVsZXRlIHRoaXMua2V5U3RvcmVba2V5XTtcbiAgICB0aGlzLmVycm9yc1N1YmplY3QubmV4dCh0aGlzLmVycm9yU3RvcmUpO1xuICAgIHRoaXMua2V5U3ViamVjdC5uZXh0KHRoaXMua2V5U3RvcmUpO1xuICB9XG5cbiAgZG9SZXRyeSgpIHtcbiAgICB0aGlzLnJldHJ5Q2xpY2tTdWJqZWN0Lm5leHQoKTtcbiAgfVxufVxuIl19
/*
* Public API Surface of ngx-error-boundary
*/
export * from './lib/ngx-error-boundary.service';
export * from './lib/ngx-error-boundary.component';
export * from './lib/ngx-error-boundary.module';
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL25neC1lcnJvci1ib3VuZGFyeS8iLCJzb3VyY2VzIjpbInB1YmxpYy1hcGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7O0dBRUc7QUFFSCxjQUFjLGtDQUFrQyxDQUFDO0FBQ2pELGNBQWMsb0NBQW9DLENBQUM7QUFDbkQsY0FBYyxpQ0FBaUMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qXG4gKiBQdWJsaWMgQVBJIFN1cmZhY2Ugb2Ygbmd4LWVycm9yLWJvdW5kYXJ5XG4gKi9cblxuZXhwb3J0ICogZnJvbSAnLi9saWIvbmd4LWVycm9yLWJvdW5kYXJ5LnNlcnZpY2UnO1xuZXhwb3J0ICogZnJvbSAnLi9saWIvbmd4LWVycm9yLWJvdW5kYXJ5LmNvbXBvbmVudCc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9uZ3gtZXJyb3ItYm91bmRhcnkubW9kdWxlJztcbiJdfQ==
export * from "./lib/ngx-error-boundary.service";
export * from "./lib/ngx-error-boundary.component";
export * from "./lib/ngx-error-boundary.module";
export * from "./lib/ngx-error-retry.directive";
export * from "./lib/ngx-error-dismiss.directive";
export * from "./lib/ngx-error-boundary.module";
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL25neC1lcnJvci1ib3VuZGFyeS8iLCJzb3VyY2VzIjpbInB1YmxpYy1hcGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7O0dBRUc7QUFFSCxjQUFjLGtDQUFrQyxDQUFDO0FBQ2pELGNBQWMsb0NBQW9DLENBQUM7QUFDbkQsY0FBYyxpQ0FBaUMsQ0FBQztBQUNoRCxjQUFjLGlDQUFpQyxDQUFDO0FBQ2hELGNBQWMsbUNBQW1DLENBQUM7QUFDbEQsY0FBYyxpQ0FBaUMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qXG4gKiBQdWJsaWMgQVBJIFN1cmZhY2Ugb2Ygbmd4LWVycm9yLWJvdW5kYXJ5XG4gKi9cblxuZXhwb3J0ICogZnJvbSBcIi4vbGliL25neC1lcnJvci1ib3VuZGFyeS5zZXJ2aWNlXCI7XG5leHBvcnQgKiBmcm9tIFwiLi9saWIvbmd4LWVycm9yLWJvdW5kYXJ5LmNvbXBvbmVudFwiO1xuZXhwb3J0ICogZnJvbSBcIi4vbGliL25neC1lcnJvci1ib3VuZGFyeS5tb2R1bGVcIjtcbmV4cG9ydCAqIGZyb20gXCIuL2xpYi9uZ3gtZXJyb3ItcmV0cnkuZGlyZWN0aXZlXCI7XG5leHBvcnQgKiBmcm9tIFwiLi9saWIvbmd4LWVycm9yLWRpc21pc3MuZGlyZWN0aXZlXCI7XG5leHBvcnQgKiBmcm9tIFwiLi9saWIvbmd4LWVycm9yLWJvdW5kYXJ5Lm1vZHVsZVwiO1xuIl19

@@ -1,12 +0,55 @@

import { __decorate } from "tslib";
import { Component } from '@angular/core';
import { __assign, __decorate, __read } from "tslib";
import { Component, Input, } from "@angular/core";
import { NgxErrorBoundaryService } from "./ngx-error-boundary.service";
import { combineLatest } from "rxjs";
import { map } from "rxjs/operators";
var NgxErrorBoundaryComponent = /** @class */ (function () {
function NgxErrorBoundaryComponent() {
function NgxErrorBoundaryComponent(errorService) {
this.errorService = errorService;
this.key = "_$ngx_error_boundary_global_error$_";
}
NgxErrorBoundaryComponent.prototype.ngOnInit = function () {
var _this = this;
this.errors$ = combineLatest([
this.errorService.errors$,
this.errorService.keys$,
]).pipe(map(function (_a) {
var _b = __read(_a, 2), errors = _b[0], keys = _b[1];
return _this.zip(errors, keys);
}));
this.isRetrying$ = this.errorService.retryStatus$.pipe(map(function (status) {
return status !== "end";
}));
};
NgxErrorBoundaryComponent.prototype.ngOnDestroy = function () {
this.sub.unsubscribe();
};
NgxErrorBoundaryComponent.prototype.zip = function (errors, keys) {
return Object.keys(keys).reduce(function (acc, curr) {
var _a;
return __assign(__assign({}, acc), (_a = {}, _a[curr] = errors[curr], _a));
}, {});
};
NgxErrorBoundaryComponent.prototype.getContext = function (error, key) {
return {
$implicit: {
message: error,
key: key,
},
retry$: this.isRetrying$,
};
};
NgxErrorBoundaryComponent.ctorParameters = function () { return [
{ type: NgxErrorBoundaryService }
]; };
__decorate([
Input()
], NgxErrorBoundaryComponent.prototype, "fallback", void 0);
__decorate([
Input()
], NgxErrorBoundaryComponent.prototype, "key", void 0);
NgxErrorBoundaryComponent = __decorate([
Component({
selector: 'lib-ngx-error-boundary',
template: "\n <p>\n ngx-error-boundary works!\n </p>\n "
selector: "ErrorBoundary",
template: "<ng-container *ngIf=\"errors$ | async as errors; else content\">\n <ng-container *ngIf=\"errors[key] as error; else content\">\n <ng-container\n [ngTemplateOutlet]=\"fallback\"\n [ngTemplateOutletContext]=\"getContext(error, key)\"\n >\n </ng-container>\n </ng-container>\n</ng-container>\n\n<ng-template #content>\n <ng-content></ng-content>\n</ng-template>\n"
})

@@ -17,2 +60,2 @@ ], NgxErrorBoundaryComponent);

export { NgxErrorBoundaryComponent };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmd4LWVycm9y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m9ycywga2V5cykpKTtcblxuICAgIHRoaXMuaXNSZXRyeWluZyQgPSB0aGlzLmVycm9yU2VydmljZS5yZXRyeVN0YXR1cyQucGlwZShcbiAgICAgIG1hcCgoc3RhdHVzKSA9PiB7XG4gICAgICAgIHJldHVybiBzdGF0dXMgIT09IFwiZW5kXCI7XG4gICAgICB9KVxuICAgICk7XG4gIH1cblxuICBuZ09uRGVzdHJveSgpIHtcbiAgICB0aGlzLnN1Yi51bnN1YnNjcmliZSgpO1xuICB9XG5cbiAgemlwKGVycm9ycywga2V5cykge1xuICAgIHJldHVybiBPYmplY3Qua2V5cyhrZXlzKS5yZWR1Y2UoKGFjYywgY3VycikgPT4ge1xuICAgICAgcmV0dXJuIHtcbiAgICAgICAgLi4uYWNjLFxuICAgICAgICBbY3Vycl06IGVycm9yc1tjdXJyXSxcbiAgICAgIH07XG4gICAgfSwge30pO1xuICB9XG5cbiAgZ2V0Q29udGV4dChlcnJvciwga2V5KSB7XG4gICAgcmV0dXJuIHtcbiAgICAgICRpbXBsaWNpdDoge1xuICAgICAgICBtZXNzYWdlOiBlcnJvcixcbiAgICAgICAga2V5LFxuICAgICAgfSxcbiAgICAgIHJldHJ5JDogdGhpcy5pc1JldHJ5aW5nJCxcbiAgICB9O1xuICB9XG59XG4iXX0=
import { __decorate } from "tslib";
import { NgModule } from '@angular/core';
import { NgxErrorBoundaryComponent } from './ngx-error-boundary.component';
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from "@angular/core";
import { NgxErrorBoundaryComponent } from "./ngx-error-boundary.component";
import { NgxErrorRetryDirective } from "./ngx-error-retry.directive";
import { NgxErrorDismissDirective } from "./ngx-error-dismiss.directive";
import { CommonModule } from "@angular/common";
var NgxErrorBoundaryModule = /** @class */ (function () {

@@ -9,5 +12,14 @@ function NgxErrorBoundaryModule() {

NgModule({
declarations: [NgxErrorBoundaryComponent],
imports: [],
exports: [NgxErrorBoundaryComponent]
declarations: [
NgxErrorBoundaryComponent,
NgxErrorRetryDirective,
NgxErrorDismissDirective,
],
imports: [CommonModule],
exports: [
NgxErrorBoundaryComponent,
NgxErrorRetryDirective,
NgxErrorDismissDirective,
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})

@@ -18,2 +30,2 @@ ], NgxErrorBoundaryModule);

export { NgxErrorBoundaryModule };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmd4LWVycm9yLWJvdW5kYXJ5Lm1vZHVsZS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL25neC1lcnJvci1ib3VuZGFyeS8iLCJzb3VyY2VzIjpbImxpYi9uZ3gtZXJyb3ItYm91bmRhcnkubW9kdWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBQ3pDLE9BQU8sRUFBRSx5QkFBeUIsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBVTNFO0lBQUE7SUFBc0MsQ0FBQztJQUExQixzQkFBc0I7UUFObEMsUUFBUSxDQUFDO1lBQ1IsWUFBWSxFQUFFLENBQUMseUJBQXlCLENBQUM7WUFDekMsT0FBTyxFQUFFLEVBQ1I7WUFDRCxPQUFPLEVBQUUsQ0FBQyx5QkFBeUIsQ0FBQztTQUNyQyxDQUFDO09BQ1csc0JBQXNCLENBQUk7SUFBRCw2QkFBQztDQUFBLEFBQXZDLElBQXVDO1NBQTFCLHNCQUFzQiIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IE5nTW9kdWxlIH0gZnJvbSAnQGFuZ3VsYXIvY29yZSc7XG5pbXBvcnQgeyBOZ3hFcnJvckJvdW5kYXJ5Q29tcG9uZW50IH0gZnJvbSAnLi9uZ3gtZXJyb3ItYm91bmRhcnkuY29tcG9uZW50JztcblxuXG5cbkBOZ01vZHVsZSh7XG4gIGRlY2xhcmF0aW9uczogW05neEVycm9yQm91bmRhcnlDb21wb25lbnRdLF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i0 from "@angular/core";
import { Injectable } from "@angular/core";
import { Subject, BehaviorSubject, Observable, throwError, } from "rxjs";
import { filter, retryWhen, delay, catchError, tap, exhaustMap, } from "rxjs/operators";
var NgxErrorBoundaryService = /** @class */ (function () {
function NgxErrorBoundaryService() {
var _this = this;
this.errorStore = {};
this.keyStore = {};
this.errorsSubject = new BehaviorSubject({});
this.keySubject = new BehaviorSubject({});
this.retryStatusSubjet = new BehaviorSubject("end");
this.retryStatus$ = this.retryStatusSubjet.asObservable();
this.retryClickSubject = new Subject();
this.retryClick$ = this.retryClickSubject.asObservable().pipe(tap(function () {
_this.retryStatusSubjet.next("start");
}));
this.errors$ = this.errorsSubject.asObservable().pipe(filter(function (message) { return !!message; }));
this.keys$ = this.keySubject.asObservable().pipe(filter(function (key) { return !!key; }));
}
NgxErrorBoundaryService.ɵprov = i0.ɵɵdefineInjectable({ factory: function NgxErrorBoundaryService_Factory() { return new NgxErrorBoundaryService(); }, token: NgxErrorBoundaryService, providedIn: "root" });
NgxErrorBoundaryService.prototype.showErrors = function (errors, key) {
var _a, _b;
if (key === void 0) { key = "_$ngx_error_boundary_global_error$_"; }
this.errorStore = Object.assign({}, this.errorStore, (_a = {}, _a[key] = errors, _a));
this.keyStore = Object.assign({}, this.keyStore, (_b = {}, _b[key] = true, _b));
this.errorsSubject.next(this.errorStore);
this.keySubject.next(this.keyStore);
};
NgxErrorBoundaryService.prototype.handleExpection = function (errorOption) {
var _this = this;
if (errorOption === void 0) { errorOption = {}; }
var message = errorOption.message, key = errorOption.key;
return function (obs$) {
return new Observable(function (subscriber) {
var sub = obs$
.pipe(catchError(function (err) {
// Catch error every time it emits
_this.retryStatusSubjet.next("end");
var readableMessage = message || JSON.stringify(err);
_this.showErrors(readableMessage, key);
return throwError(err);
}),
//retry max times
retryWhen(function (err) {
return err.pipe(exhaustMap(function () { return _this.retryClick$; }), delay(10));
}), tap(function (x) {
// Success
_this.dismiss(key);
}))
.subscribe(subscriber);
return function () {
sub.unsubscribe();
};
});
};
};
NgxErrorBoundaryService.prototype.dismiss = function (key) {
if (!key) {
// Dismis all
this.errorStore = {};
this.keyStore = {};
this.errorsSubject.next({});
this.keySubject.next({});
}
delete this.errorStore[key];
delete this.keyStore[key];
this.errorsSubject.next(this.errorStore);
this.keySubject.next(this.keyStore);
};
NgxErrorBoundaryService.prototype.doRetry = function () {
this.retryClickSubject.next();
};
NgxErrorBoundaryService = __decorate([
Injectable({
providedIn: 'root'
})
Injectable()
], NgxErrorBoundaryService);

@@ -16,2 +79,2 @@ return NgxErrorBoundaryService;

export { NgxErrorBoundaryService };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmd4LWVycm9yLWJvdW5kYXJ5LnNlcnZpY2UuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9uZ3gtZXJyb3ItYm91bmRhcnkvIiwic291cmNlcyI6WyJsaWIvbmd4LWVycm9yLWJvdW5kYXJ5LnNlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxlQUFlLENBQUM7O0FBSzNDO0lBRUU7SUFBZ0IsQ0FBQzs7SUFGTix1QkFBdUI7UUFIbkMsVUFBVSxDQUFDO1lBQ1YsVUFBVSxFQUFFLE1BQU07U0FDbkIsQ0FBQztPQUNXLHVCQUF1QixDQUduQztrQ0FSRDtDQVFDLEFBSEQsSUFHQztTQUhZLHVCQUF1QiIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IEluamVjdGFibGUgfSBmcm9tICdAYW5ndWxhci9jb3JlJztcblxuQEluamVjdGFibGUoe1xuICBwcm92aWRlZEluOiAncm9vdCdcbn0pXG5leHBvcnQgY2xhc3MgTmd4RXJyb3JCb3VuZGFyeVNlcnZpY2Uge1xuXG4gIGNvbnN0cnVjdG9yKCkgeyB9XG59XG4iXX0=
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaW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cGUoXG4gICAgICAgICAgICBjYXRjaEVycm9yKChlcnIpID0+IHtcbiAgICAgICAgICAgICAgLy8gQ2F0Y2ggZXJyb3IgZXZlcnkgdGltZSBpdCBlbWl0c1xuICAgICAgICAgICAgICB0aGlzLnJldHJ5U3RhdHVzU3ViamV0Lm5leHQoXCJlbmRcIik7XG4gICAgICAgICAgICAgIGNvbnN0IHJlYWRhYmxlTWVzc2FnZSA9IG1lc3NhZ2UgfHwgSlNPTi5zdHJpbmdpZnkoZXJyKTtcbiAgICAgICAgICAgICAgdGhpcy5zaG93RXJyb3JzKHJlYWRhYmxlTWVzc2FnZSwga2V5KTtcbiAgICAgICAgICAgICAgcmV0dXJuIHRocm93RXJyb3IoZXJyKTtcbiAgICAgICAgICAgIH0pLFxuICAgICAgICAgICAgLy9yZXRyeSBtYXggdGltZXNcbiAgICAgICAgICAgIHJldHJ5V2hlbigoZXJyKSA9PlxuICAgICAgICAgICAgICBlcnIucGlwZShcbiAgICAgICAgICAgICAgICBleGhhdXN0TWFwKCgpID0+IHRoaXMucmV0cnlDbGljayQpLFxuICAgICAgICAgICAgICAgIGRlbGF5KDEwKVxuICAgICAgICAgICAgICApXG4gICAgICAgICAgICApLFxuICAgICAgICAgICAgdGFwKCh4KSA9PiB7XG4gICAgICAgICAgICAgIC8vIFN1Y2Nlc3NcbiAgICAgICAgICAgICAgdGhpcy5kaXNtaXNzKGtleSk7XG4gICAgICAgICAgICB9KVxuICAgICAgICAgIClcbiAgICAgICAgICAuc3Vic2NyaWJlKHN1YnNjcmliZXIpO1xuXG4gICAgICAgIHJldHVybiAoKSA9PiB7XG4gICAgICAgICAgc3ViLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgIH07XG4gICAgICB9KTtcbiAgICB9O1xuICB9XG5cbiAgZGlzbWlzcyhrZXk/OiBzdHJpbmcpIHtcbiAgICBpZiAoIWtleSkge1xuICAgICAgLy8gRGlzbWlzIGFsbFxuICAgICAgdGhpcy5lcnJvclN0b3JlID0ge307XG4gICAgICB0aGlzLmtleVN0b3JlID0ge307XG4gICAgICB0aGlzLmVycm9yc1N1YmplY3QubmV4dCh7fSk7XG4gICAgICB0aGlzLmtleVN1YmplY3QubmV4dCh7fSk7XG4gICAgfVxuICAgIGRlbGV0ZSB0aGlzLmVycm9yU3RvcmVba2V5XTtcbiAgICBkZWxldGUgdGhpcy5rZXlTdG9yZVtrZXldO1xuICAgIHRoaXMuZXJyb3JzU3ViamVjdC5uZXh0KHRoaXMuZXJyb3JTdG9yZSk7XG4gICAgdGhpcy5rZXlTdWJqZWN0Lm5leHQodGhpcy5rZXlTdG9yZSk7XG4gIH1cblxuICBkb1JldHJ5KCkge1xuICAgIHRoaXMucmV0cnlDbGlja1N1YmplY3QubmV4dCgpO1xuICB9XG59XG4iXX0=
/*
* Public API Surface of ngx-error-boundary
*/
export * from './lib/ngx-error-boundary.service';
export * from './lib/ngx-error-boundary.component';
export * from './lib/ngx-error-boundary.module';
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL25neC1lcnJvci1ib3VuZGFyeS8iLCJzb3VyY2VzIjpbInB1YmxpYy1hcGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7O0dBRUc7QUFFSCxjQUFjLGtDQUFrQyxDQUFDO0FBQ2pELGNBQWMsb0NBQW9DLENBQUM7QUFDbkQsY0FBYyxpQ0FBaUMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qXG4gKiBQdWJsaWMgQVBJIFN1cmZhY2Ugb2Ygbmd4LWVycm9yLWJvdW5kYXJ5XG4gKi9cblxuZXhwb3J0ICogZnJvbSAnLi9saWIvbmd4LWVycm9yLWJvdW5kYXJ5LnNlcnZpY2UnO1xuZXhwb3J0ICogZnJvbSAnLi9saWIvbmd4LWVycm9yLWJvdW5kYXJ5LmNvbXBvbmVudCc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9uZ3gtZXJyb3ItYm91bmRhcnkubW9kdWxlJztcbiJdfQ==
export * from "./lib/ngx-error-boundary.service";
export * from "./lib/ngx-error-boundary.component";
export * from "./lib/ngx-error-boundary.module";
export * from "./lib/ngx-error-retry.directive";
export * from "./lib/ngx-error-dismiss.directive";
export * from "./lib/ngx-error-boundary.module";
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL25neC1lcnJvci1ib3VuZGFyeS8iLCJzb3VyY2VzIjpbInB1YmxpYy1hcGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7O0dBRUc7QUFFSCxjQUFjLGtDQUFrQyxDQUFDO0FBQ2pELGNBQWMsb0NBQW9DLENBQUM7QUFDbkQsY0FBYyxpQ0FBaUMsQ0FBQztBQUNoRCxjQUFjLGlDQUFpQyxDQUFDO0FBQ2hELGNBQWMsbUNBQW1DLENBQUM7QUFDbEQsY0FBYyxpQ0FBaUMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qXG4gKiBQdWJsaWMgQVBJIFN1cmZhY2Ugb2Ygbmd4LWVycm9yLWJvdW5kYXJ5XG4gKi9cblxuZXhwb3J0ICogZnJvbSBcIi4vbGliL25neC1lcnJvci1ib3VuZGFyeS5zZXJ2aWNlXCI7XG5leHBvcnQgKiBmcm9tIFwiLi9saWIvbmd4LWVycm9yLWJvdW5kYXJ5LmNvbXBvbmVudFwiO1xuZXhwb3J0ICogZnJvbSBcIi4vbGliL25neC1lcnJvci1ib3VuZGFyeS5tb2R1bGVcIjtcbmV4cG9ydCAqIGZyb20gXCIuL2xpYi9uZ3gtZXJyb3ItcmV0cnkuZGlyZWN0aXZlXCI7XG5leHBvcnQgKiBmcm9tIFwiLi9saWIvbmd4LWVycm9yLWRpc21pc3MuZGlyZWN0aXZlXCI7XG5leHBvcnQgKiBmcm9tIFwiLi9saWIvbmd4LWVycm9yLWJvdW5kYXJ5Lm1vZHVsZVwiO1xuIl19
import { __decorate } from 'tslib';
import { ɵɵdefineInjectable, Injectable, Component, NgModule } from '@angular/core';
import { Injectable, Input, Component, HostListener, Directive, NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { BehaviorSubject, Subject, Observable, throwError, combineLatest } from 'rxjs';
import { tap, filter, catchError, retryWhen, exhaustMap, delay, map } from 'rxjs/operators';
import { CommonModule } from '@angular/common';
let NgxErrorBoundaryService = class NgxErrorBoundaryService {
constructor() { }
constructor() {
this.errorStore = {};
this.keyStore = {};
this.errorsSubject = new BehaviorSubject({});
this.keySubject = new BehaviorSubject({});
this.retryStatusSubjet = new BehaviorSubject("end");
this.retryStatus$ = this.retryStatusSubjet.asObservable();
this.retryClickSubject = new Subject();
this.retryClick$ = this.retryClickSubject.asObservable().pipe(tap(() => {
this.retryStatusSubjet.next("start");
}));
this.errors$ = this.errorsSubject.asObservable().pipe(filter((message) => !!message));
this.keys$ = this.keySubject.asObservable().pipe(filter((key) => !!key));
}
showErrors(errors, key = "_$ngx_error_boundary_global_error$_") {
this.errorStore = Object.assign({}, this.errorStore, { [key]: errors });
this.keyStore = Object.assign({}, this.keyStore, { [key]: true });
this.errorsSubject.next(this.errorStore);
this.keySubject.next(this.keyStore);
}
handleExpection(errorOption = {}) {
const { message, key } = errorOption;
return (obs$) => {
return new Observable((subscriber) => {
const sub = obs$
.pipe(catchError((err) => {
// Catch error every time it emits
this.retryStatusSubjet.next("end");
const readableMessage = message || JSON.stringify(err);
this.showErrors(readableMessage, key);
return throwError(err);
}),
//retry max times
retryWhen((err) => err.pipe(exhaustMap(() => this.retryClick$), delay(10))), tap((x) => {
// Success
this.dismiss(key);
}))
.subscribe(subscriber);
return () => {
sub.unsubscribe();
};
});
};
}
dismiss(key) {
if (!key) {
// Dismis all
this.errorStore = {};
this.keyStore = {};
this.errorsSubject.next({});
this.keySubject.next({});
}
delete this.errorStore[key];
delete this.keyStore[key];
this.errorsSubject.next(this.errorStore);
this.keySubject.next(this.keyStore);
}
doRetry() {
this.retryClickSubject.next();
}
};
NgxErrorBoundaryService.ɵprov = ɵɵdefineInjectable({ factory: function NgxErrorBoundaryService_Factory() { return new NgxErrorBoundaryService(); }, token: NgxErrorBoundaryService, providedIn: "root" });
NgxErrorBoundaryService = __decorate([
Injectable({
providedIn: 'root'
})
Injectable()
], NgxErrorBoundaryService);
let NgxErrorBoundaryComponent = class NgxErrorBoundaryComponent {
constructor() { }
constructor(errorService) {
this.errorService = errorService;
this.key = "_$ngx_error_boundary_global_error$_";
}
ngOnInit() {
this.errors$ = combineLatest([
this.errorService.errors$,
this.errorService.keys$,
]).pipe(map(([errors, keys]) => this.zip(errors, keys)));
this.isRetrying$ = this.errorService.retryStatus$.pipe(map((status) => {
return status !== "end";
}));
}
ngOnDestroy() {
this.sub.unsubscribe();
}
zip(errors, keys) {
return Object.keys(keys).reduce((acc, curr) => {
return Object.assign(Object.assign({}, acc), { [curr]: errors[curr] });
}, {});
}
getContext(error, key) {
return {
$implicit: {
message: error,
key,
},
retry$: this.isRetrying$,
};
}
};
NgxErrorBoundaryComponent.ctorParameters = () => [
{ type: NgxErrorBoundaryService }
];
__decorate([
Input()
], NgxErrorBoundaryComponent.prototype, "fallback", void 0);
__decorate([
Input()
], NgxErrorBoundaryComponent.prototype, "key", void 0);
NgxErrorBoundaryComponent = __decorate([
Component({
selector: 'lib-ngx-error-boundary',
template: `
<p>
ngx-error-boundary works!
</p>
`
selector: "ErrorBoundary",
template: "<ng-container *ngIf=\"errors$ | async as errors; else content\">\n <ng-container *ngIf=\"errors[key] as error; else content\">\n <ng-container\n [ngTemplateOutlet]=\"fallback\"\n [ngTemplateOutletContext]=\"getContext(error, key)\"\n >\n </ng-container>\n </ng-container>\n</ng-container>\n\n<ng-template #content>\n <ng-content></ng-content>\n</ng-template>\n"
})
], NgxErrorBoundaryComponent);
let NgxErrorRetryDirective = class NgxErrorRetryDirective {
constructor(errorService) {
this.errorService = errorService;
}
onClick() {
this.errorService.doRetry();
}
ngOnInit() { }
};
NgxErrorRetryDirective.ctorParameters = () => [
{ type: NgxErrorBoundaryService }
];
__decorate([
HostListener("click")
], NgxErrorRetryDirective.prototype, "onClick", null);
NgxErrorRetryDirective = __decorate([
Directive({
selector: "[errorRetry]",
exportAs: "retry",
})
], NgxErrorRetryDirective);
let NgxErrorDismissDirective = class NgxErrorDismissDirective {
constructor(errorService) {
this.errorService = errorService;
}
onClick() {
this.errorService.dismiss(this.errorDismiss);
}
};
NgxErrorDismissDirective.ctorParameters = () => [
{ type: NgxErrorBoundaryService }
];
__decorate([
Input()
], NgxErrorDismissDirective.prototype, "errorDismiss", void 0);
__decorate([
HostListener("click")
], NgxErrorDismissDirective.prototype, "onClick", null);
NgxErrorDismissDirective = __decorate([
Directive({
selector: "[errorDismiss]",
exportAs: "dismiss",
})
], NgxErrorDismissDirective);
let NgxErrorBoundaryModule = class NgxErrorBoundaryModule {

@@ -34,5 +171,14 @@ };

NgModule({
declarations: [NgxErrorBoundaryComponent],
imports: [],
exports: [NgxErrorBoundaryComponent]
declarations: [
NgxErrorBoundaryComponent,
NgxErrorRetryDirective,
NgxErrorDismissDirective,
],
imports: [CommonModule],
exports: [
NgxErrorBoundaryComponent,
NgxErrorRetryDirective,
NgxErrorDismissDirective,
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})

@@ -49,3 +195,3 @@ ], NgxErrorBoundaryModule);

export { NgxErrorBoundaryComponent, NgxErrorBoundaryModule, NgxErrorBoundaryService };
export { NgxErrorBoundaryComponent, NgxErrorBoundaryModule, NgxErrorBoundaryService, NgxErrorDismissDirective, NgxErrorRetryDirective };
//# sourceMappingURL=ngx-error-boundary.js.map

@@ -1,12 +0,77 @@

import { __decorate } from 'tslib';
import { ɵɵdefineInjectable, Injectable, Component, NgModule } from '@angular/core';
import { __decorate, __read, __assign } from 'tslib';
import { Injectable, Input, Component, HostListener, Directive, NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { BehaviorSubject, Subject, Observable, throwError, combineLatest } from 'rxjs';
import { tap, filter, catchError, retryWhen, exhaustMap, delay, map } from 'rxjs/operators';
import { CommonModule } from '@angular/common';
var NgxErrorBoundaryService = /** @class */ (function () {
function NgxErrorBoundaryService() {
var _this = this;
this.errorStore = {};
this.keyStore = {};
this.errorsSubject = new BehaviorSubject({});
this.keySubject = new BehaviorSubject({});
this.retryStatusSubjet = new BehaviorSubject("end");
this.retryStatus$ = this.retryStatusSubjet.asObservable();
this.retryClickSubject = new Subject();
this.retryClick$ = this.retryClickSubject.asObservable().pipe(tap(function () {
_this.retryStatusSubjet.next("start");
}));
this.errors$ = this.errorsSubject.asObservable().pipe(filter(function (message) { return !!message; }));
this.keys$ = this.keySubject.asObservable().pipe(filter(function (key) { return !!key; }));
}
NgxErrorBoundaryService.ɵprov = ɵɵdefineInjectable({ factory: function NgxErrorBoundaryService_Factory() { return new NgxErrorBoundaryService(); }, token: NgxErrorBoundaryService, providedIn: "root" });
NgxErrorBoundaryService.prototype.showErrors = function (errors, key) {
var _a, _b;
if (key === void 0) { key = "_$ngx_error_boundary_global_error$_"; }
this.errorStore = Object.assign({}, this.errorStore, (_a = {}, _a[key] = errors, _a));
this.keyStore = Object.assign({}, this.keyStore, (_b = {}, _b[key] = true, _b));
this.errorsSubject.next(this.errorStore);
this.keySubject.next(this.keyStore);
};
NgxErrorBoundaryService.prototype.handleExpection = function (errorOption) {
var _this = this;
if (errorOption === void 0) { errorOption = {}; }
var message = errorOption.message, key = errorOption.key;
return function (obs$) {
return new Observable(function (subscriber) {
var sub = obs$
.pipe(catchError(function (err) {
// Catch error every time it emits
_this.retryStatusSubjet.next("end");
var readableMessage = message || JSON.stringify(err);
_this.showErrors(readableMessage, key);
return throwError(err);
}),
//retry max times
retryWhen(function (err) {
return err.pipe(exhaustMap(function () { return _this.retryClick$; }), delay(10));
}), tap(function (x) {
// Success
_this.dismiss(key);
}))
.subscribe(subscriber);
return function () {
sub.unsubscribe();
};
});
};
};
NgxErrorBoundaryService.prototype.dismiss = function (key) {
if (!key) {
// Dismis all
this.errorStore = {};
this.keyStore = {};
this.errorsSubject.next({});
this.keySubject.next({});
}
delete this.errorStore[key];
delete this.keyStore[key];
this.errorsSubject.next(this.errorStore);
this.keySubject.next(this.keyStore);
};
NgxErrorBoundaryService.prototype.doRetry = function () {
this.retryClickSubject.next();
};
NgxErrorBoundaryService = __decorate([
Injectable({
providedIn: 'root'
})
Injectable()
], NgxErrorBoundaryService);

@@ -17,10 +82,50 @@ return NgxErrorBoundaryService;

var NgxErrorBoundaryComponent = /** @class */ (function () {
function NgxErrorBoundaryComponent() {
function NgxErrorBoundaryComponent(errorService) {
this.errorService = errorService;
this.key = "_$ngx_error_boundary_global_error$_";
}
NgxErrorBoundaryComponent.prototype.ngOnInit = function () {
var _this = this;
this.errors$ = combineLatest([
this.errorService.errors$,
this.errorService.keys$,
]).pipe(map(function (_a) {
var _b = __read(_a, 2), errors = _b[0], keys = _b[1];
return _this.zip(errors, keys);
}));
this.isRetrying$ = this.errorService.retryStatus$.pipe(map(function (status) {
return status !== "end";
}));
};
NgxErrorBoundaryComponent.prototype.ngOnDestroy = function () {
this.sub.unsubscribe();
};
NgxErrorBoundaryComponent.prototype.zip = function (errors, keys) {
return Object.keys(keys).reduce(function (acc, curr) {
var _a;
return __assign(__assign({}, acc), (_a = {}, _a[curr] = errors[curr], _a));
}, {});
};
NgxErrorBoundaryComponent.prototype.getContext = function (error, key) {
return {
$implicit: {
message: error,
key: key,
},
retry$: this.isRetrying$,
};
};
NgxErrorBoundaryComponent.ctorParameters = function () { return [
{ type: NgxErrorBoundaryService }
]; };
__decorate([
Input()
], NgxErrorBoundaryComponent.prototype, "fallback", void 0);
__decorate([
Input()
], NgxErrorBoundaryComponent.prototype, "key", void 0);
NgxErrorBoundaryComponent = __decorate([
Component({
selector: 'lib-ngx-error-boundary',
template: "\n <p>\n ngx-error-boundary works!\n </p>\n "
selector: "ErrorBoundary",
template: "<ng-container *ngIf=\"errors$ | async as errors; else content\">\n <ng-container *ngIf=\"errors[key] as error; else content\">\n <ng-container\n [ngTemplateOutlet]=\"fallback\"\n [ngTemplateOutletContext]=\"getContext(error, key)\"\n >\n </ng-container>\n </ng-container>\n</ng-container>\n\n<ng-template #content>\n <ng-content></ng-content>\n</ng-template>\n"
})

@@ -31,2 +136,50 @@ ], NgxErrorBoundaryComponent);

var NgxErrorRetryDirective = /** @class */ (function () {
function NgxErrorRetryDirective(errorService) {
this.errorService = errorService;
}
NgxErrorRetryDirective.prototype.onClick = function () {
this.errorService.doRetry();
};
NgxErrorRetryDirective.prototype.ngOnInit = function () { };
NgxErrorRetryDirective.ctorParameters = function () { return [
{ type: NgxErrorBoundaryService }
]; };
__decorate([
HostListener("click")
], NgxErrorRetryDirective.prototype, "onClick", null);
NgxErrorRetryDirective = __decorate([
Directive({
selector: "[errorRetry]",
exportAs: "retry",
})
], NgxErrorRetryDirective);
return NgxErrorRetryDirective;
}());
var NgxErrorDismissDirective = /** @class */ (function () {
function NgxErrorDismissDirective(errorService) {
this.errorService = errorService;
}
NgxErrorDismissDirective.prototype.onClick = function () {
this.errorService.dismiss(this.errorDismiss);
};
NgxErrorDismissDirective.ctorParameters = function () { return [
{ type: NgxErrorBoundaryService }
]; };
__decorate([
Input()
], NgxErrorDismissDirective.prototype, "errorDismiss", void 0);
__decorate([
HostListener("click")
], NgxErrorDismissDirective.prototype, "onClick", null);
NgxErrorDismissDirective = __decorate([
Directive({
selector: "[errorDismiss]",
exportAs: "dismiss",
})
], NgxErrorDismissDirective);
return NgxErrorDismissDirective;
}());
var NgxErrorBoundaryModule = /** @class */ (function () {

@@ -37,5 +190,14 @@ function NgxErrorBoundaryModule() {

NgModule({
declarations: [NgxErrorBoundaryComponent],
imports: [],
exports: [NgxErrorBoundaryComponent]
declarations: [
NgxErrorBoundaryComponent,
NgxErrorRetryDirective,
NgxErrorDismissDirective,
],
imports: [CommonModule],
exports: [
NgxErrorBoundaryComponent,
NgxErrorRetryDirective,
NgxErrorDismissDirective,
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})

@@ -54,3 +216,3 @@ ], NgxErrorBoundaryModule);

export { NgxErrorBoundaryComponent, NgxErrorBoundaryModule, NgxErrorBoundaryService };
export { NgxErrorBoundaryComponent, NgxErrorBoundaryModule, NgxErrorBoundaryService, NgxErrorDismissDirective, NgxErrorRetryDirective };
//# sourceMappingURL=ngx-error-boundary.js.map

@@ -1,5 +0,24 @@

import { OnInit } from '@angular/core';
export declare class NgxErrorBoundaryComponent implements OnInit {
constructor();
import { OnInit, TemplateRef, OnDestroy } from "@angular/core";
import { NgxErrorBoundaryService } from "./ngx-error-boundary.service";
import { Observable } from "rxjs";
export declare class NgxErrorBoundaryComponent implements OnInit, OnDestroy {
private errorService;
fallback: TemplateRef<any>;
key: string;
private sub;
errors$: Observable<{
[key: string]: string;
}>;
isRetrying$: Observable<boolean>;
constructor(errorService: NgxErrorBoundaryService);
ngOnInit(): void;
ngOnDestroy(): void;
zip(errors: any, keys: any): {};
getContext(error: any, key: any): {
$implicit: {
message: any;
key: any;
};
retry$: Observable<boolean>;
};
}

@@ -0,3 +1,26 @@

import { Observable } from "rxjs";
export interface INgxErrorOption {
message?: string;
key?: string;
}
export declare class NgxErrorBoundaryService {
private errorStore;
private keyStore;
private errorsSubject;
private keySubject;
private retryStatusSubjet;
retryStatus$: Observable<string>;
private retryClickSubject;
retryClick$: Observable<unknown>;
errors$: Observable<{
[key: string]: string;
}>;
keys$: Observable<{
[key: string]: boolean;
}>;
constructor();
private showErrors;
handleExpection(errorOption?: INgxErrorOption): (obs$: any) => Observable<any>;
dismiss(key?: string): void;
doRetry(): void;
}

@@ -1,1 +0,1 @@

{"__symbolic":"module","version":4,"metadata":{"NgxErrorBoundaryService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":2,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor"}]},"statics":{"ɵprov":{}}},"NgxErrorBoundaryComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component","line":2,"character":1},"arguments":[{"selector":"lib-ngx-error-boundary","template":"\n <p>\n ngx-error-boundary works!\n </p>\n ","styles":[]}]}],"members":{"__ctor__":[{"__symbolic":"constructor"}],"ngOnInit":[{"__symbolic":"method"}]}},"NgxErrorBoundaryModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":5,"character":1},"arguments":[{"declarations":[{"__symbolic":"reference","name":"NgxErrorBoundaryComponent"}],"imports":[],"exports":[{"__symbolic":"reference","name":"NgxErrorBoundaryComponent"}]}]}],"members":{}}},"origins":{"NgxErrorBoundaryService":"./lib/ngx-error-boundary.service","NgxErrorBoundaryComponent":"./lib/ngx-error-boundary.component","NgxErrorBoundaryModule":"./lib/ngx-error-boundary.module"},"importAs":"ngx-error-boundary"}
{"__symbolic":"module","version":4,"metadata":{"INgxErrorOption":{"__symbolic":"interface"},"NgxErrorBoundaryService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":22,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor"}],"showErrors":[{"__symbolic":"method"}],"handleExpection":[{"__symbolic":"method"}],"dismiss":[{"__symbolic":"method"}],"doRetry":[{"__symbolic":"method"}]}},"NgxErrorBoundaryComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component","line":11,"character":1},"arguments":[{"selector":"ErrorBoundary","template":"<ng-container *ngIf=\"errors$ | async as errors; else content\">\n <ng-container *ngIf=\"errors[key] as error; else content\">\n <ng-container\n [ngTemplateOutlet]=\"fallback\"\n [ngTemplateOutletContext]=\"getContext(error, key)\"\n >\n </ng-container>\n </ng-container>\n</ng-container>\n\n<ng-template #content>\n <ng-content></ng-content>\n</ng-template>\n"}]}],"members":{"fallback":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":16,"character":3}}]}],"key":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":17,"character":3}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"NgxErrorBoundaryService"}]}],"ngOnInit":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}],"zip":[{"__symbolic":"method"}],"getContext":[{"__symbolic":"method"}]}},"NgxErrorBoundaryModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":6,"character":1},"arguments":[{"declarations":[{"__symbolic":"reference","name":"NgxErrorBoundaryComponent"},{"__symbolic":"reference","name":"NgxErrorRetryDirective"},{"__symbolic":"reference","name":"NgxErrorDismissDirective"}],"imports":[{"__symbolic":"reference","module":"@angular/common","name":"CommonModule","line":12,"character":12}],"exports":[{"__symbolic":"reference","name":"NgxErrorBoundaryComponent"},{"__symbolic":"reference","name":"NgxErrorRetryDirective"},{"__symbolic":"reference","name":"NgxErrorDismissDirective"}],"schemas":[{"__symbolic":"reference","module":"@angular/core","name":"CUSTOM_ELEMENTS_SCHEMA","line":18,"character":12}]}]}],"members":{}},"NgxErrorRetryDirective":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive","line":3,"character":1},"arguments":[{"selector":"[errorRetry]","exportAs":"retry"}]}],"members":{"onClick":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"HostListener","line":8,"character":3},"arguments":["click"]}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"NgxErrorBoundaryService"}]}],"ngOnInit":[{"__symbolic":"method"}]}},"NgxErrorDismissDirective":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive","line":3,"character":1},"arguments":[{"selector":"[errorDismiss]","exportAs":"dismiss"}]}],"members":{"errorDismiss":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":8,"character":3}}]}],"onClick":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"HostListener","line":10,"character":3},"arguments":["click"]}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"NgxErrorBoundaryService"}]}]}}},"origins":{"INgxErrorOption":"./lib/ngx-error-boundary.service","NgxErrorBoundaryService":"./lib/ngx-error-boundary.service","NgxErrorBoundaryComponent":"./lib/ngx-error-boundary.component","NgxErrorBoundaryModule":"./lib/ngx-error-boundary.module","NgxErrorRetryDirective":"./lib/ngx-error-retry.directive","NgxErrorDismissDirective":"./lib/ngx-error-dismiss.directive"},"importAs":"ngx-error-boundary"}
{
"name": "ngx-error-boundary",
"version": "0.0.1-alpha.0",
"version": "0.0.1",
"peerDependencies": {
"@angular/common": "^9.1.1",
"@angular/core": "^9.1.1",
"@angular/common": "^9.1.0",
"@angular/core": "^9.1.0",
"tslib": "^1.10.0"

@@ -8,0 +8,0 @@ },

@@ -1,3 +0,6 @@

export * from './lib/ngx-error-boundary.service';
export * from './lib/ngx-error-boundary.component';
export * from './lib/ngx-error-boundary.module';
export * from "./lib/ngx-error-boundary.service";
export * from "./lib/ngx-error-boundary.component";
export * from "./lib/ngx-error-boundary.module";
export * from "./lib/ngx-error-retry.directive";
export * from "./lib/ngx-error-dismiss.directive";
export * from "./lib/ngx-error-boundary.module";
# NgxErrorBoundary
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.
This library is an experimental implementation of React Error boundary for Angular.
## Code scaffolding
## [DEMO]()
Run `ng generate component component-name --project ngx-error-boundary` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project ngx-error-boundary`.
> Note: Don't forget to add `--project ngx-error-boundary` or else it will be added to the default project in your `angular.json` file.
## Install the library
## Build
```bash
npm i ngx-error-boundary --save
```
Run `ng build ngx-error-boundary` to build the project. The build artifacts will be stored in the `dist/` directory.
Import the module:
## Publishing
```typescript
imports: [NgxErrorBoundaryModule];
```
After building your library with `ng build ngx-error-boundary`, go to the dist folder `cd dist/ngx-error-boundary` and run `npm publish`.
Once you include the module, you will get following component that you can use:
## Running unit tests
```html
<ErrorBoundary
[fallback]="template"
key="unique.identify.string"
></ErrorBoundary>
```
Run `ng test ngx-error-boundary` to execute the unit tests via [Karma](https://karma-runner.github.io).
following directives:
## Further help
```typescript
errorRetry;
errorDismiss;
```
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
and also you got one service:
```typescript
NgxErrorBoundaryService;
```
## Usage
### `<ErrorBoundary>`
Using `[fallback]` with `<ng-template></ng-template>`, `key` is optional if there is only one `ErrorBoundary` pre-component.
If there are multi `ErrorBoundary` inside one component, you need to use `key` to show correct error message
```html
<!-- error: {message: string, key: string} -->
<!-- retry$: Observable<boolean>: is retrying -->
<ng-template #errTemplate let-error let-retry$="retry$">
<div class="err-container">
<h2>Something goes wrong!</h2>
<section>
<p [innerHTML]="error.message"></p>
<!-- errorRetry can help to retry the failed observable -->
<button errorRetry>
{{ (retry$ | async) ? "Retrying..." : "Retry" }}
</button>
<!-- errorDismiss: hide error boundary -->
<button [errorDismiss]="error.key">Dismiss</button>
</section>
</div>
</ng-template>
<ErrorBoundary [fallback]="errTemplate" key="example">
<YOUR_CONTENT_FROM_SERVER [data]="data$ | async" />
</ErrorBoundary>
```
```typescript
this.data$ = timer(500).pipe(
this.apiService.fetchData(),
this.errorService.handleExpection({
message: "Cannot load data",
key: "example",
})
);
```
When there is error, `<YOUR_CONTENT_FROM_SERVER [data]="data$ | async" />` will be repalced with `errTemplate`.
#### `@Input() fallback: TemplateRef`
Take an `ng-template` as input.
#### `@Input() key: string`
A string to unqiue identify string to show correct error message
---
### `errorRetry` Directive
You can retry the failed observable.
### `errorDismiss` Directive
Take error's key string as input.
To hide Error boundary component
---
### `NgxErrorBoundaryService`
#### `handleExpection({message?: string, key?: string})`
If nothing passed in as arguement, will use catched error's message information.
There is a default key assigned, can be used for global error message.
**Example:**
```typescript
@Component({
selector: "categories",
...
providers: [NgxErrorBoundaryService],
})
export class CategoriesComponent {
categories$: Observable<Category[]>;
constructor(
private categoriesService: CategoriesService,
private errorService: NgxErrorBoundaryService
) {
this.categories$ = this.categoriesService.fetchData().pipe(
this.errorService.handleExpection({
message: "Cannot load categories",
key: "categories",
})
);
}
}
```
#### `dismiss(key?: string)`
key: error key
Hide error boundary component and error message for the key.
If didn't pass key, then hide all error messages.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc