UNPKG

@zodiac-ui/ng-observable

Version:

Create powerful reactive components with Angular. AoT compatible and Ivy ready.

1,384 lines (1,355 loc) 46.4 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('rxjs'), require('@angular/core'), require('rxjs/operators')) : typeof define === 'function' && define.amd ? define('@zodiac-ui/ng-observable', ['exports', 'rxjs', '@angular/core', 'rxjs/operators'], factory) : (global = global || self, factory((global['zodiac-ui'] = global['zodiac-ui'] || {}, global['zodiac-ui']['ng-observable'] = {}), global.rxjs, global.ng.core, global.rxjs.operators)); }(this, function (exports, rxjs, core, operators) { '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 __()); } function __values(o) { var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; if (m) return m.call(o); return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; } 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 */ /** * @param {?} derivedCtor * @param {?} baseCtors * @return {?} */ function applyMixins(derivedCtor, baseCtors) { baseCtors.forEach((/** * @param {?} baseCtor * @return {?} */ function (baseCtor) { Object.getOwnPropertyNames(baseCtor.prototype).forEach((/** * @param {?} name * @return {?} */ function (name) { Object.defineProperty(derivedCtor.prototype, name, Object.getOwnPropertyDescriptor(baseCtor.prototype, name) || {}); })); })); } /** @type {?} */ var mixins = Symbol(); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @template T */ var /** * @template T */ Callable = /** @class */ (function (_super) { __extends(Callable, _super); function Callable(fn) { var _newTarget = this.constructor; var _this = _super.call(this) || this; return Object.setPrototypeOf(fn, _newTarget.prototype); } return Callable; }(Function)); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ // WARNING: interface has both a type and a value, skipping emit /** * A subject that implements both `Subject<T>` and `Function` interfaces. Using this subject in place of a normal * method turns all invocations of that method into an observable stream without needing to modify the source of * the caller. When called with multiple arguments it will emit the arguments as an array. * * \@usageNotes * * Basic usage * * ```ts * const subject = new InvokeSubject<string>() // single argument * const subject2 = new InvokeSubject<[string, number]>() // multiple arguments * * subject("message") * subject2("message", 42) * * // with custom invoke function * const subject3 = new InvokeSubject<string>(function () { * subject3.next("message") // call "next" to emit value * }) * ``` * * Convert `\@HostListener` and `(event)` bindings into observable streams * * ```ts * \@Component({ * template: `<input type="text" (input)="inputChanges($event)" />` * }) * export class MyComponent implements OnDestroy { * \@HostListener("click", ["$event"]) * readonly hostClick = new InvokeSubject<MouseEvent>() * readonly inputChanges = new InvokeSubject<Event>() * * constructor() { * hostClick.subscribe(event => console.log(event)) * inputChanges.subscribe(event => console.log(event)) * } * } * ``` * * \@publicApi * @template T */ var InvokeSubject = /** @class */ (function (_super) { __extends(InvokeSubject, _super); /** * Creates a new `InvokeSubject` instance * * @param nextFn A function to be called when the subject is invoked * */ function InvokeSubject(nextFn) { var _this = _super.call(this, nextFn ? nextFn : (/** * @param {...?} args * @return {?} */ function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } /** @type {?} */ var len = args.length; if (len === 0) { _this.next(); } else if (len === 1) { _this.next(args[0]); } else { _this.next(args); } })) || this; Object.assign(_this, new rxjs.Subject()); return _this; } var _a; _a = mixins; InvokeSubject[_a] = applyMixins(InvokeSubject, [rxjs.Observable, rxjs.Subject]); return InvokeSubject; }(Callable)); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @param {...?} flags * @return {?} */ function createMask() { var flags = []; for (var _i = 0; _i < arguments.length; _i++) { flags[_i] = arguments[_i]; } /** @type {?} */ var len = flags.length; /** @type {?} */ var count = 0; while (len--) { count += flags[len]; } return count; } /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * Future API for declaring lifecycle hooks at runtime without extending a base class. Will * become available if/when Angular supports runtime lifecycle hooks that work AoT or when * the compiler can be configured to add lifecycle features without adding them to the class. * * @param {...?} flags Enum flags for toggling which lifecycle hooks to enable * * @return {?} */ function UseHooks() { var flags = []; for (var _i = 0; _i < arguments.length; _i++) { flags[_i] = arguments[_i]; } /** @type {?} */ var features = createMask.apply(void 0, __spread(flags)); return (/** * @param {?} target * @return {?} */ function (target) { if (features & 1) { target.prototype.ngOnChanges = new InvokeSubject(target.prototype.ngOnChanges); } if (features & 2) { target.prototype.ngOnInit = new InvokeSubject(target.prototype.ngOnInit); } if (features & 4) { target.prototype.ngDoCheck = new InvokeSubject(target.prototype.ngDoCheck); } if (features & 8) { target.prototype.ngAfterContentInit = new InvokeSubject(target.prototype.ngAfterContentInit); } if (features & 16) { target.prototype.ngAfterContentChecked = new InvokeSubject(target.prototype.ngAfterContentChecked); } if (features & 32) { target.prototype.ngAfterViewInit = new InvokeSubject(target.prototype.ngAfterViewInit); } if (features & 64) { target.prototype.ngAfterViewChecked = new InvokeSubject(target.prototype.ngAfterViewChecked); } if (features & 128) { target.prototype.ngOnDestroy = new InvokeSubject(target.prototype.ngOnDestroy); } }); } /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * Implements all of the builtin lifecycle hooks provided by Angular and makes them observable. * * \@usageNotes * * ```ts * \@Component() * export class MyComponent extends NgObservable { * constructor() { * ngOnInit(this).subscribe(() => { * console.log("ngOnInit") * }) * } * } * ``` * * \@publicApi * @abstract */ var NgObservable = /** @class */ (function () { function NgObservable() { } /** * OnChanges lifecycle hook * * @param changes Simple changes can be strongly typed where input props are known */ /** * OnChanges lifecycle hook * * @param {?} changes Simple changes can be strongly typed where input props are known * @return {?} */ NgObservable.prototype.ngOnChanges = /** * OnChanges lifecycle hook * * @param {?} changes Simple changes can be strongly typed where input props are known * @return {?} */ function (changes) { ((/** @type {?} */ (this.ngOnChanges))).next([this, changes]); }; /** * OnInit lifecycle hook */ /** * OnInit lifecycle hook * @return {?} */ NgObservable.prototype.ngOnInit = /** * OnInit lifecycle hook * @return {?} */ function () { ((/** @type {?} */ (this.ngOnInit))).next(this); }; /** * ngDoCheck lifecycle hook */ /** * ngDoCheck lifecycle hook * @return {?} */ NgObservable.prototype.ngDoCheck = /** * ngDoCheck lifecycle hook * @return {?} */ function () { ((/** @type {?} */ (this.ngDoCheck))).next(this); }; /** * ngAfterContentInit lifecycle hook */ /** * ngAfterContentInit lifecycle hook * @return {?} */ NgObservable.prototype.ngAfterContentInit = /** * ngAfterContentInit lifecycle hook * @return {?} */ function () { ((/** @type {?} */ (this.ngAfterContentInit))).next(this); }; /** * ngAfterContentChecked lifecycle hook */ /** * ngAfterContentChecked lifecycle hook * @return {?} */ NgObservable.prototype.ngAfterContentChecked = /** * ngAfterContentChecked lifecycle hook * @return {?} */ function () { ((/** @type {?} */ (this.ngAfterContentChecked))).next(this); }; /** * ngAfterViewInit lifecycle hook */ /** * ngAfterViewInit lifecycle hook * @return {?} */ NgObservable.prototype.ngAfterViewInit = /** * ngAfterViewInit lifecycle hook * @return {?} */ function () { ((/** @type {?} */ (this.ngAfterViewInit))).next(this); }; /** * ngAfterViewChecked lifecycle hook */ /** * ngAfterViewChecked lifecycle hook * @return {?} */ NgObservable.prototype.ngAfterViewChecked = /** * ngAfterViewChecked lifecycle hook * @return {?} */ function () { ((/** @type {?} */ (this.ngAfterViewChecked))).next(this); }; /** * ngOnDestroy lifecycle hook */ /** * ngOnDestroy lifecycle hook * @return {?} */ NgObservable.prototype.ngOnDestroy = /** * ngOnDestroy lifecycle hook * @return {?} */ function () { ((/** @type {?} */ (this.ngOnDestroy))).next(this); }; var _a; _a = mixins; NgObservable[_a] = UseHooks(255)(NgObservable); return NgObservable; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @enum {number} */ var StateChangeStrategy = { /** * If detached, reattaches the `ChangeDetectorRef` and allows `OnPush` and `Default` change * detection strategies to trigger change detection. If using "noop" zones, this setting has * no effect. */ REATTACH: 0, /** * When using this strategy, the `ChangeDetectorRef` is automatically detached after the first render. * All change detection must be performed manually by calling `detectChanges` on `ChangeDetectorRef` * or by using {@link StateFactory} and calling {@link State#next}. * */ DETACH: 1, }; StateChangeStrategy[StateChangeStrategy.REATTACH] = 'REATTACH'; StateChangeStrategy[StateChangeStrategy.DETACH] = 'DETACH'; /** * Provider token for {\@link StateChangeStrategy} * @type {?} */ var STATE_CHANGE_STRATEGY = new core.InjectionToken("STATE_CHANGE_STRATEGY"); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * Configures the change detection strategy for the current injector when used with {\@link StateFactory} * * When using `DETACH` mode the change detector is detached after the first * change detection run and each component must manually call `State#next` * or `ChangeDetectorRef#detectChanges` afterwards to * re-render the template. This behaviour ignores any setting of * `ChangeDetectionStrategy` at the compiler or component level. `REATTACH` * will reattach the `ChangeDetectorRef` when the `State` is instantiated. * * @see {\@link StateChangeStrategy.DETACH} / {\@link StateChangeStrategy.REATTACH} * * \@usageNotes * * ```typescript * \@Component({ * providers: [ * useStateChangeStrategy( * StateChangeStrategy.DETACH, // or REATTACH * ), * ], * }) * export class AppComponent {} * ``` * * \@publicApi * * @param {?} strategy A flag to determine the change detection strategy that should be used. * * @return {?} */ function useStateChangeStrategy(strategy) { return { provide: STATE_CHANGE_STRATEGY, useValue: strategy, }; } /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @param {?} obj * @return {?} */ function isCompletionObserver(obj) { return typeof obj && typeof obj["complete"] === "function"; } /** * @param {?} obj * @return {?} */ function isUnsubscribable(obj) { return typeof obj && typeof obj["unsubscribe"] === "function"; } /** * @param {?} teardown * @return {?} */ function isTeardownLogic(teardown) { return (teardown === null || typeof teardown === "undefined" || (typeof teardown === "function" || typeof teardown["unsubscribe"] === "function")); } /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @param {?} sub * @return {?} */ function createStream(sub) { return (/** * @param {...?} targets * @return {?} */ function stream() { var targets = []; for (var _i = 0; _i < arguments.length; _i++) { targets[_i] = arguments[_i]; } return (/** * @param {...?} sources * @return {?} */ function () { var e_1, _a; var sources = []; for (var _i = 0; _i < arguments.length; _i++) { sources[_i] = arguments[_i]; } try { for (var sources_1 = __values(sources), sources_1_1 = sources_1.next(); !sources_1_1.done; sources_1_1 = sources_1.next()) { var source = sources_1_1.value; sub.add(rxjs.from(source).subscribe((/** * @param {?} value * @return {?} */ function (value) { var e_2, _a; try { for (var targets_1 = __values(targets), targets_1_1 = targets_1.next(); !targets_1_1.done; targets_1_1 = targets_1.next()) { var target = targets_1_1.value; if (typeof target === "function") { target(value); } else { target.next(value); } } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (targets_1_1 && !targets_1_1.done && (_a = targets_1.return)) _a.call(targets_1); } finally { if (e_2) throw e_2.error; } } }))); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (sources_1_1 && !sources_1_1.done && (_a = sources_1.return)) _a.call(sources_1); } finally { if (e_1) throw e_1.error; } } }); }); } // WARNING: interface has both a type and a value, skipping emit /** * Automatically subscribes to source observables and forwards their values to target observers while * discarding error and completion events. Cleans up all subscriptions when the stream completes by manually calling `complete` * or when the bound injector is destroyed. * * \@usageNotes * * Basic usage * * ```ts * const stream = new Stream() * const dest = new Subject() * const source = interval(1000) * * stream(dest)(source) * * stream.sink = source * stream.add(source) * * // unsubscribe from all sources * stream.complete() * ``` * * With `State` * * ```typescript * * \@Component({ * viewProviders: [StateFactory] // or providers * }) * export class MyComponent { * count: number * * constructor(stateFactory: StateFactory) { * const state = stateFactory.create(this) * * // update count once per second * // automatically unsubscribe when component is destroyed * stream(state)(interval(1000).pipe( * map(count => ({ count })) * )) * } * } * ``` * * \@publicApi */ var Stream = /** @class */ (function (_super) { __extends(Stream, _super); function Stream() { var _this = this; /** @type {?} */ var sub = new rxjs.Subscription(); _this = _super.call(this, createStream(sub)) || this; _this.sub = sub; return _this; } Object.defineProperty(Stream.prototype, "sink", { /** * A subscription or an observable of teardown logic that will be cleaned up * when the stream ends. */ set: /** * A subscription or an observable of teardown logic that will be cleaned up * when the stream ends. * @param {?} sinkable * @return {?} */ function (sinkable) { var _this = this; var e_3, _a; if (!sinkable) { return; } if (isTeardownLogic(sinkable)) { this.sub.add(sinkable); } else if (Array.isArray(sinkable)) { try { for (var sinkable_1 = __values(sinkable), sinkable_1_1 = sinkable_1.next(); !sinkable_1_1.done; sinkable_1_1 = sinkable_1.next()) { var stream = sinkable_1_1.value; this.sink = stream; } } catch (e_3_1) { e_3 = { error: e_3_1 }; } finally { try { if (sinkable_1_1 && !sinkable_1_1.done && (_a = sinkable_1.return)) _a.call(sinkable_1); } finally { if (e_3) throw e_3.error; } } } else { this.sink = rxjs.from(sinkable).subscribe((/** * @param {?} stream * @return {?} */ function (stream) { _this.sink = stream; })); } }, enumerable: true, configurable: true }); /** * Alternative to {@link sink} * * @param sinkables A series of {@link Sinkable} to be cleaned up when the stream ends. */ /** * Alternative to {\@link sink} * * @param {...?} sinkables A series of {\@link Sinkable} to be cleaned up when the stream ends. * @return {?} */ Stream.prototype.add = /** * Alternative to {\@link sink} * * @param {...?} sinkables A series of {\@link Sinkable} to be cleaned up when the stream ends. * @return {?} */ function () { var sinkables = []; for (var _i = 0; _i < arguments.length; _i++) { sinkables[_i] = arguments[_i]; } this.sink = sinkables; }; /** * Completes the stream and unsubscribes from all sources. */ /** * Completes the stream and unsubscribes from all sources. * @return {?} */ Stream.prototype.complete = /** * Completes the stream and unsubscribes from all sources. * @return {?} */ function () { this.sub.unsubscribe(); }; /** * `OnDestroy` hook called by Angular when the bound injector is destroyed */ /** * `OnDestroy` hook called by Angular when the bound injector is destroyed * @return {?} */ Stream.prototype.ngOnDestroy = /** * `OnDestroy` hook called by Angular when the bound injector is destroyed * @return {?} */ function () { this.complete(); }; Stream.decorators = [ { type: core.Injectable } ]; /** @nocollapse */ Stream.ctorParameters = function () { return []; }; return Stream; }(Callable)); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * State object for bound `valueRef`. State changes mutate the original object in-place and notifies any observers * with a new object reference. * * @see {\@link StateFactory} * * \@usageNotes * * \@publicApi * @template T */ var /** * State object for bound `valueRef`. State changes mutate the original object in-place and notifies any observers * with a new object reference. * * @see {\@link StateFactory} * * \@usageNotes * * \@publicApi * @template T */ State = /** @class */ (function (_super) { __extends(State, _super); /** * Creates a new State `instance`. * * @param valueRef The mutable value object reference to apply state changes to. * @param markForCheck Notifier that schedules change detection to run on the next microtask. */ function State(valueRef, markForCheck) { var _this = _super.call(this, Object.create(valueRef)) || this; _this.valueRef = valueRef; _this.next = (/** * @param {?=} partialState * @return {?} */ function (partialState) { _this.patchValue(partialState); markForCheck(); }); _this.patchValue = (/** * @param {?=} partialState * @return {?} */ function (partialState) { Object.assign(valueRef, partialState); _super.prototype.next.call(_this, Object.create(valueRef)); }); return _this; } return State; }(rxjs.BehaviorSubject)); /** * Reactive state management for Angular components and directives. * * @see {\@link State} * * \@usageNotes * * Create a `State<T>` instance by passing the component instance as an argument. All mutations to * the internal component state should be handled with this service so that observers can be notified * of changes. * * ```typescript * export interface MyProps { * title: string * } * * export interface MyState extends MyProps { * model: string * } * * \@Component({ * viewProviders: [StateFactory, Stream] // or providers * }) * export class MyComponent implements MyState { * \@Input() * title: string * model: string * * constructor(\@Self() stateFactory: StateFactory<MyState>, \@Self() stream: Stream) { * const state = stateFactory.create(this) * * // Imperative usage * state.next({ * model: "app" * }) * * // Reactive usage * stream(state)(of({ model: "app" })) * } * } * ``` * * ### Connecting `\@Input()` properties * * Changes received from `\@Input()` properties can be mapped onto the state to keep state observers up to date: * * ```ts * \@Component() * export class MyComponent extends NgObservable implements MyState { * \@Input() * value: any * mappedValue: any * * constructor(\@Self() stateFactory: StateFactory<MyState>, \@Self() stream: Stream) { * const state = stateFactory.create(this) * * // assuming 1:1 map between inputs and state * stream(state)(mapInputsToState(this)) * * // map inputs to some other value * stream(state)(mapInputsToState(this).pipe( * map((props) => ({ * mappedValue: props.value * })) * ) * } * } * ``` * * \@publicApi * @template T */ var StateFactory = /** @class */ (function () { /** * Creates an instance of `StateFactory` * * @param strategy The {@link StateChangeStrategy} to be used. It will wither detach or reattach * the `ChangeDetectorRef` if one is provided. * * @param cdr The `ChangeDetectorRef` for the current view. * */ function StateFactory(strategy, cdr) { this.stream = new Stream(); this.cdr = cdr; this.strategy = strategy; this.checkNoChanges = core.isDevMode(); } /** * Creates an instance of {@link State} bound to the given `valueRef`. Performs change detection when notified * by `markForCheck`. * * @param valueRef The mutable value object reference to apply state changes to. */ /** * Creates an instance of {\@link State} bound to the given `valueRef`. Performs change detection when notified * by `markForCheck`. * * @param {?} valueRef The mutable value object reference to apply state changes to. * @return {?} */ StateFactory.prototype.create = /** * Creates an instance of {\@link State} bound to the given `valueRef`. Performs change detection when notified * by `markForCheck`. * * @param {?} valueRef The mutable value object reference to apply state changes to. * @return {?} */ function (valueRef) { var _a = this, cdr = _a.cdr, strategy = _a.strategy, stream = _a.stream, checkNoChanges = _a.checkNoChanges; /** @type {?} */ var markForCheck = new InvokeSubject(); /** @type {?} */ var state = new State(valueRef, markForCheck); /** @type {?} */ var shouldDetach = strategy === StateChangeStrategy.DETACH; if (cdr) { /** @type {?} */ var detectChanges_1 = (/** * @return {?} */ function () { cdr.detectChanges(); if (checkNoChanges) { cdr.checkNoChanges(); } }); if (shouldDetach) { cdr.detach(); } else { cdr.reattach(); } Promise.resolve().then((/** * @return {?} */ function () { if (shouldDetach) { detectChanges_1(); } stream(detectChanges_1)(operators.debounceTime(0, rxjs.asapScheduler)(markForCheck)); })); } return state; }; /** * Cleanup when the injector is destroyed */ /** * Cleanup when the injector is destroyed * @return {?} */ StateFactory.prototype.ngOnDestroy = /** * Cleanup when the injector is destroyed * @return {?} */ function () { this.stream.complete(); }; StateFactory.decorators = [ { type: core.Injectable } ]; /** @nocollapse */ StateFactory.ctorParameters = function () { return [ { type: StateChangeStrategy, decorators: [{ type: core.Inject, args: [STATE_CHANGE_STRATEGY,] }] }, { type: core.ChangeDetectorRef, decorators: [{ type: core.Optional }] } ]; }; return StateFactory; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @template T * @param {?} prototype * @param {?} key * @param {?} mapper * @return {?} */ function makePropertyMapper(prototype, key, mapper) { Object.defineProperty(prototype, key, { set: /** * @return {?} */ function () { /** @type {?} */ var getValue = mapper(); Object.defineProperty(this, key, { get: /** * @return {?} */ function () { return getValue(Object.create(this)); }, enumerable: true, }); }, enumerable: true, configurable: true, }); } /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @param {?} decorator * @return {?} */ function makePropDecorator(decorator) { return decorator; } /** * @template R, T, U * @param {?} selectorFactory * @return {?} */ function computed(selectorFactory) { return (/** * @param {?} target * @param {?} propertyKey * @return {?} */ function (target, propertyKey) { makePropertyMapper(target, propertyKey, selectorFactory); }); } /** * @param {?} target * @param {?} propertyKey * @param {?} name * @return {?} */ function decorateLifecycle(target, propertyKey, name) { /** @type {?} */ var originalHook = target[name]; target[name] = new InvokeSubject((/** * @this {?} * @param {...?} args * @return {?} */ function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } this[propertyKey].apply(this, args); originalHook.apply(this, args); })); } /** * @template T * @return {?} */ function ngOnChanges() { return (/** * @param {?} target * @param {?} propertyKey * @return {?} */ function (target, propertyKey) { return decorateLifecycle(target, propertyKey, "ngOnChanges"); }); } /** * @template T * @return {?} */ function ngOnInit() { return (/** * @param {?} target * @param {?} propertyKey * @return {?} */ function (target, propertyKey) { return decorateLifecycle(target, propertyKey, "ngOnInit"); }); } /** * @template T * @return {?} */ function ngAfterContentChecked() { return (/** * @param {?} target * @param {?} propertyKey * @return {?} */ function (target, propertyKey) { return decorateLifecycle(target, propertyKey, "ngAfterContentChecked"); }); } /** * @template T * @return {?} */ function ngAfterViewChecked() { return (/** * @param {?} target * @param {?} propertyKey * @return {?} */ function (target, propertyKey) { return decorateLifecycle(target, propertyKey, "ngAfterViewChecked"); }); } /** * @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 * @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 ngAfterViewInit(source) { return createLifecycleHook(source, "ngAfterViewInit", true); } /** * @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 */ // WARNING: interface has both a type and a value, skipping emit /** * \@Annotation * \@publicApi * @type {?} */ var Computed = makePropDecorator(computed) /** * Type of the NgOnChangesDecorator decorator / constructor function. * * @publicApi */ ; // WARNING: interface has both a type and a value, skipping emit /** * \@Annotation * \@publicApi * @type {?} */ var NgOnChanges = makePropDecorator(ngOnChanges) /** * Type of the NgOnChangesDecorator decorator / constructor function. * * @publicApi */ ; // WARNING: interface has both a type and a value, skipping emit /** * \@Annotation * \@publicApi * @type {?} */ var NgOnInit = makePropDecorator(ngOnInit) /** * Type of the NgOnChangesDecorator decorator / constructor function. * * @publicApi */ ; // WARNING: interface has both a type and a value, skipping emit /** * \@Annotation * \@publicApi * @type {?} */ var NgDoCheck = makePropDecorator(ngDoCheck) /** * Type of the NgOnChangesDecorator decorator / constructor function. * * @publicApi */ ; // WARNING: interface has both a type and a value, skipping emit /** * \@Annotation * \@publicApi * @type {?} */ var NgAfterContentInit = makePropDecorator(ngAfterContentInit) /** * Type of the NgOnChangesDecorator decorator / constructor function. * * @publicApi */ ; // WARNING: interface has both a type and a value, skipping emit /** * \@Annotation * \@publicApi * @type {?} */ var NgAfterContentChecked = makePropDecorator(ngAfterContentChecked) /** * Type of the NgOnChangesDecorator decorator / constructor function. * * @publicApi */ ; // WARNING: interface has both a type and a value, skipping emit /** * \@Annotation * \@publicApi * @type {?} */ var NgAfterViewInit = makePropDecorator(ngAfterViewInit) /** * Type of the NgOnChangesDecorator decorator / constructor function. * * @publicApi */ ; // WARNING: interface has both a type and a value, skipping emit /** * \@Annotation * \@publicApi * @type {?} */ var NgAfterViewChecked = makePropDecorator(ngAfterViewChecked) /** * Type of the NgOnChangesDecorator decorator / constructor function. * * @publicApi */ ; // WARNING: interface has both a type and a value, skipping emit /** * \@Annotation * \@publicApi * @type {?} */ var NgOnDestroy = makePropDecorator(ngOnDestroy); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * Convenience function for cleaning up multiple subscriptions. * * @param {...?} unsubscribables A series of subscriptions or completable subjects to unsubscribe from. * @return {?} */ function unsubscribe() { var e_1, _a; var unsubscribables = []; for (var _i = 0; _i < arguments.length; _i++) { unsubscribables[_i] = arguments[_i]; } try { for (var unsubscribables_1 = __values(unsubscribables), unsubscribables_1_1 = unsubscribables_1.next(); !unsubscribables_1_1.done; unsubscribables_1_1 = unsubscribables_1.next()) { var subscriber = unsubscribables_1_1.value; if (isCompletionObserver(subscriber)) { subscriber.complete(); } if (isUnsubscribable(subscriber)) { subscriber.unsubscribe(); } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (unsubscribables_1_1 && !unsubscribables_1_1.done && (_a = unsubscribables_1.return)) _a.call(unsubscribables_1); } finally { if (e_1) throw e_1.error; } } } exports.Computed = Computed; exports.InvokeSubject = InvokeSubject; exports.NgAfterContentChecked = NgAfterContentChecked; exports.NgAfterContentInit = NgAfterContentInit; exports.NgAfterViewChecked = NgAfterViewChecked; exports.NgAfterViewInit = NgAfterViewInit; exports.NgDoCheck = NgDoCheck; exports.NgObservable = NgObservable; exports.NgOnChanges = NgOnChanges; exports.NgOnDestroy = NgOnDestroy; exports.NgOnInit = NgOnInit; exports.STATE_CHANGE_STRATEGY = STATE_CHANGE_STRATEGY; exports.State = State; exports.StateChangeStrategy = StateChangeStrategy; exports.StateFactory = StateFactory; exports.Stream = Stream; exports.unsubscribe = unsubscribe; exports.useStateChangeStrategy = useStateChangeStrategy; exports.ɵa = Callable; exports.ɵb = makePropDecorator; exports.ɵc = computed; exports.ɵd = ngOnChanges; exports.ɵe = ngOnInit; exports.ɵf = ngAfterContentChecked; exports.ɵg = ngAfterViewChecked; exports.ɵh = ngDoCheck; exports.ɵi = ngAfterContentInit; exports.ɵj = ngAfterViewInit; exports.ɵk = ngOnDestroy; exports.ɵl = createLifecycleHook; Object.defineProperty(exports, '__esModule', { value: true }); })); //# sourceMappingURL=zodiac-ui-ng-observable.umd.js.map