@zodiac-ui/ng-observable
Version:
Create powerful reactive components with Angular. AoT compatible and Ivy ready.
221 lines (208 loc) • 7.46 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('rxjs/operators'), require('rxjs')) :
typeof define === 'function' && define.amd ? define('@zodiac-ui/ng-observable/operators', ['exports', 'rxjs/operators', 'rxjs'], factory) :
(global = global || self, factory((global['zodiac-ui'] = global['zodiac-ui'] || {}, global['zodiac-ui']['ng-observable'] = global['zodiac-ui']['ng-observable'] || {}, global['zodiac-ui']['ng-observable'].operators = {}), global.rxjs.operators, global.rxjs));
}(this, function (exports, operators, rxjs) { '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.
***************************************************************************** */
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;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @template U, V
* @param {?} source
* @param {?} name
* @param {?=} once
* @param {?=} pipes
* @return {?}
*/
function createLifecycleHook(source, name, once, pipes) {
if (pipes === void 0) { pipes = [operators.filter((/**
* @param {?} inst
* @return {?}
*/
function (inst) { return inst === source; }))]; }
/** @type {?} */
var hook = source[name];
if (once) {
pipes.push(operators.take(1));
}
if (rxjs.isObservable(hook)) {
return ((/** @type {?} */ (hook))).pipe.apply(((/** @type {?} */ (hook))), __spread(pipes));
}
else {
console.error(name + " is not an observable! Error context: ", source);
throw new Error();
}
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @template T, U
* @param {?} source
* @return {?}
*/
function ngOnChanges(source) {
/** @type {?} */
var onChangesPipe = [operators.filter((/**
* @param {?} args
* @return {?}
*/
function (args) { return args[0] === source; })), operators.map((/**
* @param {?} args
* @return {?}
*/
function (args) { return args[1]; }))];
return createLifecycleHook(source, "ngOnChanges", false, onChangesPipe);
}
/**
* @template T
* @param {?} source
* @return {?}
*/
function ngOnInit(source) {
return createLifecycleHook(source, "ngOnInit", true);
}
/**
* @template T
* @param {?} source
* @return {?}
*/
function ngDoCheck(source) {
return createLifecycleHook(source, "ngDoCheck");
}
/**
* @template T
* @param {?} source
* @return {?}
*/
function ngAfterContentInit(source) {
return createLifecycleHook(source, "ngAfterContentInit", true);
}
/**
* @template T
* @param {?} source
* @return {?}
*/
function ngAfterContentChecked(source) {
return createLifecycleHook(source, "ngAfterContentChecked");
}
/**
* @template T
* @param {?} source
* @return {?}
*/
function ngAfterViewInit(source) {
return createLifecycleHook(source, "ngAfterViewInit", true);
}
/**
* @template T
* @param {?} source
* @return {?}
*/
function ngAfterViewChecked(source) {
return createLifecycleHook(source, "ngAfterViewChecked");
}
/**
* @template T
* @param {?} source
* @return {?}
*/
function ngOnDestroy(source) {
return createLifecycleHook(source, "ngOnDestroy", true);
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @template T, U
* @param {...?} args
* @return {?}
*/
function select() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
/** @type {?} */
var selector = args[args.length - 1];
/**
* @param {?} source
* @return {?}
*/
function pipeState(source) {
return source.pipe(operators.map(selector), operators.distinctUntilChanged());
}
return args.length > 1 ? pipeState(args[0]) : pipeState;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @template T
* @param {?=} value
* @return {?}
*/
function defaultMapFn(value) {
return value;
}
/**
* @template T, U
* @param {?} source
* @param {?=} mapFn
* @return {?}
*/
function mapInputsToState(source, mapFn) {
if (mapFn === void 0) { mapFn = defaultMapFn; }
return ngOnChanges(source).pipe(operators.mapTo(Object.create(source)), operators.map(mapFn));
}
exports.mapInputsToState = mapInputsToState;
exports.ngAfterContentChecked = ngAfterContentChecked;
exports.ngAfterContentInit = ngAfterContentInit;
exports.ngAfterViewChecked = ngAfterViewChecked;
exports.ngAfterViewInit = ngAfterViewInit;
exports.ngDoCheck = ngDoCheck;
exports.ngOnChanges = ngOnChanges;
exports.ngOnDestroy = ngOnDestroy;
exports.ngOnInit = ngOnInit;
exports.select = select;
exports.ɵa = createLifecycleHook;
Object.defineProperty(exports, '__esModule', { value: true });
}));
//# sourceMappingURL=zodiac-ui-ng-observable-operators.umd.js.map