@one-paragon/angular-utilities 0.1.14 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/ngrx/actionable-selector.mjs +76 -0
- package/esm2020/ngrx/index.mjs +2 -0
- package/esm2020/public-api.mjs +2 -1
- package/esm2020/rxjs/index.mjs +2 -1
- package/esm2020/rxjs/subjectifier.mjs +15 -0
- package/fesm2015/one-paragon-angular-utilities.mjs +90 -2
- package/fesm2015/one-paragon-angular-utilities.mjs.map +1 -1
- package/fesm2020/one-paragon-angular-utilities.mjs +90 -2
- package/fesm2020/one-paragon-angular-utilities.mjs.map +1 -1
- package/ngrx/actionable-selector.d.ts +15 -0
- package/ngrx/index.d.ts +1 -0
- package/package.json +1 -1
- package/public-api.d.ts +1 -0
- package/rxjs/index.d.ts +1 -0
- package/rxjs/subjectifier.d.ts +9 -0
|
@@ -68,7 +68,7 @@ import * as i7$2 from '@angular/material/chips';
|
|
|
68
68
|
import { MatChipsModule } from '@angular/material/chips';
|
|
69
69
|
import * as i8$2 from '@angular/material/button-toggle';
|
|
70
70
|
import * as i3$4 from '@ngrx/store';
|
|
71
|
-
import { createSelector, createAction, props, select, createReducer, on, StoreModule, createFeatureSelector } from '@ngrx/store';
|
|
71
|
+
import { createSelector, createAction, props, select, createReducer, on, StoreModule, createFeatureSelector, Store } from '@ngrx/store';
|
|
72
72
|
import * as i1$3 from '@ngrx/effects';
|
|
73
73
|
import { createEffect, ofType, concatLatestFrom, EffectsModule } from '@ngrx/effects';
|
|
74
74
|
import { createEntityAdapter } from '@ngrx/entity';
|
|
@@ -2098,6 +2098,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImpor
|
|
|
2098
2098
|
args: [MatMenuTrigger]
|
|
2099
2099
|
}] } });
|
|
2100
2100
|
|
|
2101
|
+
class Subjectifier extends Observable {
|
|
2102
|
+
constructor(_source) {
|
|
2103
|
+
super((obs) => {
|
|
2104
|
+
const s = merge(_source, this._subj).subscribe(obs);
|
|
2105
|
+
return s;
|
|
2106
|
+
});
|
|
2107
|
+
this._source = _source;
|
|
2108
|
+
this._subj = new Subject();
|
|
2109
|
+
this.merged = merge(this._source, this._subj);
|
|
2110
|
+
this.next = this._subj.next.bind(this._subj);
|
|
2111
|
+
this.newSubj = (...operations) => new Subjectifier(this.merged.pipe(...operations));
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2101
2115
|
class ResizeColumnDirective {
|
|
2102
2116
|
constructor(renderer, el, store) {
|
|
2103
2117
|
this.renderer = renderer;
|
|
@@ -4436,6 +4450,80 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImpor
|
|
|
4436
4450
|
* Public API Surface of action-state
|
|
4437
4451
|
*/
|
|
4438
4452
|
|
|
4453
|
+
class AppStoreCache {
|
|
4454
|
+
constructor() {
|
|
4455
|
+
this.cache = [];
|
|
4456
|
+
this.isInCache = (props, actionableSelectorId) => {
|
|
4457
|
+
if (typeof props != 'object')
|
|
4458
|
+
props = { props };
|
|
4459
|
+
const valueToCache = { ...props, actionableSelectorId$: actionableSelectorId };
|
|
4460
|
+
if (this.cache.some(item => shallowEquals(item, valueToCache))) {
|
|
4461
|
+
return true;
|
|
4462
|
+
}
|
|
4463
|
+
this.cache.push(valueToCache);
|
|
4464
|
+
return false;
|
|
4465
|
+
};
|
|
4466
|
+
}
|
|
4467
|
+
}
|
|
4468
|
+
let _store;
|
|
4469
|
+
let _cache = new AppStoreCache();
|
|
4470
|
+
const setStore = (store) => {
|
|
4471
|
+
if (store instanceof Store)
|
|
4472
|
+
_store = store;
|
|
4473
|
+
};
|
|
4474
|
+
function setUpStoreFactory(store) {
|
|
4475
|
+
return () => new Promise((resolve, reject) => {
|
|
4476
|
+
setStore(store);
|
|
4477
|
+
resolve(null);
|
|
4478
|
+
});
|
|
4479
|
+
}
|
|
4480
|
+
/**
|
|
4481
|
+
* Creates a selector that can dispatch an action if conditions are met.
|
|
4482
|
+
* Note: The props of the selector factory must include the props of the action.
|
|
4483
|
+
* @param selectorFactory A method that returns selector.
|
|
4484
|
+
* @param action The action that will be dispatched when conditions are met.
|
|
4485
|
+
* @param [dispatchIf = defaultFilter] Optional. A method that takes the result of the selector and returns a boolean. The actions gets dispatched
|
|
4486
|
+
* if true is returned. If no method is passed in than the action will be dispatched if the selector returns undefined or null.
|
|
4487
|
+
*/
|
|
4488
|
+
const createActionableSelector = (selectorFactory, action, dispatchIf = defaultFilter) => {
|
|
4489
|
+
const id = v4();
|
|
4490
|
+
const slctr = (props) => createSelector(selectorFactory(props), (selected) => {
|
|
4491
|
+
if (dispatchIf(selected) && !_cache.isInCache(props, id)) {
|
|
4492
|
+
//Adding the null check for testing purposes. Otherwise it should never be null.
|
|
4493
|
+
_store.dispatch(action(props));
|
|
4494
|
+
}
|
|
4495
|
+
return selected;
|
|
4496
|
+
});
|
|
4497
|
+
return slctr;
|
|
4498
|
+
};
|
|
4499
|
+
function defaultFilter(data) {
|
|
4500
|
+
return data == null || data == undefined;
|
|
4501
|
+
}
|
|
4502
|
+
/**
|
|
4503
|
+
* Returns a shallow clone without prop. Will not error if prop does not exist.
|
|
4504
|
+
* @param prop name of property to be removed.
|
|
4505
|
+
* @returns a shallow clone without prop
|
|
4506
|
+
*/
|
|
4507
|
+
const deleteProp = (t, prop) => {
|
|
4508
|
+
const copy = { ...t };
|
|
4509
|
+
delete copy[prop];
|
|
4510
|
+
return copy;
|
|
4511
|
+
};
|
|
4512
|
+
const shallowEquals = (first, second) => {
|
|
4513
|
+
const firstKeys = Object.keys(first);
|
|
4514
|
+
const secondKeys = Object.keys(second);
|
|
4515
|
+
if (firstKeys.length !== secondKeys.length) {
|
|
4516
|
+
return false;
|
|
4517
|
+
}
|
|
4518
|
+
for (let index = 0; index < firstKeys.length; index++) {
|
|
4519
|
+
const currentKey = firstKeys[index];
|
|
4520
|
+
if (first[currentKey] !== second[currentKey]) {
|
|
4521
|
+
return false;
|
|
4522
|
+
}
|
|
4523
|
+
}
|
|
4524
|
+
return true;
|
|
4525
|
+
};
|
|
4526
|
+
|
|
4439
4527
|
/*
|
|
4440
4528
|
* Public API Surface of http-request-state
|
|
4441
4529
|
*/
|
|
@@ -4444,5 +4532,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImpor
|
|
|
4444
4532
|
* Generated bundle index. Do not edit.
|
|
4445
4533
|
*/
|
|
4446
4534
|
|
|
4447
|
-
export { ActionStateSpinnerComponent, ActionStateUiModule, ActionStatus, AppStatusState, ArrayStyle, AutoFocusDirective, ClickEmitterDirective, ClickSubjectDirective, ConditionalClassesDirective, CreateTableBuilder, CustomCellDirective, DateFilterComponent, DialogDirective, DialogService, DialogWrapper, FieldType, FilterChipsComponent, FilterComponent, FilterType, FunctionPipe, GenColDisplayerComponent, GenFilterDisplayerComponent, GeneralTableSettings, GenericTableComponent, HttpErrorStateDirective, HttpInProgressStateDirective, HttpNotStartedStateDirective, HttpRequestModule, HttpRequestStateDirective, HttpRequestStateFactory, HttpRequestStateStore, HttpRequestStatus, HttpRequestStrategy, HttpSuccessStateDirective, MatButtonToggleFilterDirective, MatCheckboxTbFilterDirective, MatOptionTbFilterDirective, MatRadioButtonTbFilterDirective, MatSlideToggleGroupDirective, MatSlideToggleTbFilterDirective, MatTableObservableDataSource, MultiSortDirective, NgrxExtModule, NotPersisitedTableSettings, PaginatorComponent, PesrsistedTableSettings, PhoneNumberPipe, PreventEnterDirective, ResizeColumnDirective, SortDirection, SpaceCasePipe, StopPropagationDirective, StylerDirective, TableBuilder, TableBuilderModule, TableColumnHeaderSettings, TableContainerComponent, TableCustomFilterDirective, TableCustomFilterDirectiveBase, TableFilterDirective, TableFilterStringContainsDirective, TableWrapperDirective, TableWrapperFooterSettings, TableWrapperHeaderSettings, Target, TbSelectedFilterDirective, UtilitiesModule, actionStatusReducer, chainRequest, combineArrays, createFailure, createSuccess, defaultShareReplay, delayOn, filterArray, getRequestorBody, getRequestorStatus, getStatusState, httpRequest, httpRequestor, inProgress, initialState, isErrorState, isSuccessState, mapArray, mapError, notNull, notStarted, onWait, onceWhen, previousAndCurrent, selectAll, selectEntities, selectEntity, selectIds, selectTotal, serverStatusTypes, skipOneWhen, spaceCase, statusAdapter, statusIsSuccessOrInProgress, switchOff, tapError, tapSuccess };
|
|
4535
|
+
export { ActionStateSpinnerComponent, ActionStateUiModule, ActionStatus, AppStatusState, ArrayStyle, AutoFocusDirective, ClickEmitterDirective, ClickSubjectDirective, ConditionalClassesDirective, CreateTableBuilder, CustomCellDirective, DateFilterComponent, DialogDirective, DialogService, DialogWrapper, FieldType, FilterChipsComponent, FilterComponent, FilterType, FunctionPipe, GenColDisplayerComponent, GenFilterDisplayerComponent, GeneralTableSettings, GenericTableComponent, HttpErrorStateDirective, HttpInProgressStateDirective, HttpNotStartedStateDirective, HttpRequestModule, HttpRequestStateDirective, HttpRequestStateFactory, HttpRequestStateStore, HttpRequestStatus, HttpRequestStrategy, HttpSuccessStateDirective, MatButtonToggleFilterDirective, MatCheckboxTbFilterDirective, MatOptionTbFilterDirective, MatRadioButtonTbFilterDirective, MatSlideToggleGroupDirective, MatSlideToggleTbFilterDirective, MatTableObservableDataSource, MultiSortDirective, NgrxExtModule, NotPersisitedTableSettings, PaginatorComponent, PesrsistedTableSettings, PhoneNumberPipe, PreventEnterDirective, ResizeColumnDirective, SortDirection, SpaceCasePipe, StopPropagationDirective, StylerDirective, Subjectifier, TableBuilder, TableBuilderModule, TableColumnHeaderSettings, TableContainerComponent, TableCustomFilterDirective, TableCustomFilterDirectiveBase, TableFilterDirective, TableFilterStringContainsDirective, TableWrapperDirective, TableWrapperFooterSettings, TableWrapperHeaderSettings, Target, TbSelectedFilterDirective, UtilitiesModule, actionStatusReducer, chainRequest, combineArrays, createActionableSelector, createFailure, createSuccess, defaultFilter, defaultShareReplay, delayOn, filterArray, getRequestorBody, getRequestorStatus, getStatusState, httpRequest, httpRequestor, inProgress, initialState, isErrorState, isSuccessState, mapArray, mapError, notNull, notStarted, onWait, onceWhen, previousAndCurrent, selectAll, selectEntities, selectEntity, selectIds, selectTotal, serverStatusTypes, setUpStoreFactory, skipOneWhen, spaceCase, statusAdapter, statusIsSuccessOrInProgress, switchOff, tapError, tapSuccess };
|
|
4448
4536
|
//# sourceMappingURL=one-paragon-angular-utilities.mjs.map
|