ngx-bootstrap-mini-ngrx.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import { BehaviorSubject, queueScheduler, Observable } from 'rxjs';
  2. import { observeOn, scan, map, distinctUntilChanged } from 'rxjs/operators';
  3. /**
  4. * @fileoverview added by tsickle
  5. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  6. */
  7. /**
  8. * @template T
  9. */
  10. class MiniState extends BehaviorSubject {
  11. /**
  12. * @param {?} _initialState
  13. * @param {?} actionsDispatcher$
  14. * @param {?} reducer
  15. */
  16. constructor(_initialState, actionsDispatcher$, reducer) {
  17. super(_initialState);
  18. /** @type {?} */
  19. const actionInQueue$ = actionsDispatcher$.pipe(observeOn(queueScheduler));
  20. /** @type {?} */
  21. const state$ = actionInQueue$.pipe(scan((/**
  22. * @param {?} state
  23. * @param {?} action
  24. * @return {?}
  25. */
  26. (state, action) => {
  27. if (!action) {
  28. return state;
  29. }
  30. return reducer(state, action);
  31. }), _initialState));
  32. state$.subscribe((/**
  33. * @param {?} value
  34. * @return {?}
  35. */
  36. (value) => this.next(value)));
  37. }
  38. }
  39. /**
  40. * @fileoverview added by tsickle
  41. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  42. */
  43. /**
  44. * @template T
  45. */
  46. class MiniStore extends Observable {
  47. /**
  48. * @param {?} _dispatcher
  49. * @param {?} _reducer
  50. * @param {?} state$
  51. */
  52. constructor(_dispatcher, _reducer,
  53. /* tslint:disable-next-line: no-any */
  54. state$) {
  55. super();
  56. this._dispatcher = _dispatcher;
  57. this._reducer = _reducer;
  58. /* tslint:disable-next-line: deprecation */
  59. this.source = state$;
  60. }
  61. /**
  62. * @template R
  63. * @param {?} pathOrMapFn
  64. * @return {?}
  65. */
  66. select(pathOrMapFn) {
  67. /* tslint:disable-next-line: deprecation */
  68. /** @type {?} */
  69. const mapped$ = this.source.pipe(map(pathOrMapFn));
  70. return mapped$.pipe(distinctUntilChanged());
  71. }
  72. /**
  73. * @template R
  74. * @param {?} operator
  75. * @return {?}
  76. */
  77. lift(operator) {
  78. /** @type {?} */
  79. const store = new MiniStore(this._dispatcher, this._reducer, this);
  80. /* tslint:disable-next-line: deprecation */
  81. store.operator = operator;
  82. return store;
  83. }
  84. /**
  85. * @param {?} action
  86. * @return {?}
  87. */
  88. dispatch(action) {
  89. this._dispatcher.next(action);
  90. }
  91. /**
  92. * @param {?} action
  93. * @return {?}
  94. */
  95. next(action) {
  96. this._dispatcher.next(action);
  97. }
  98. /* tslint:disable-next-line: no-any */
  99. /**
  100. * @param {?} err
  101. * @return {?}
  102. */
  103. error(err) {
  104. this._dispatcher.error(err);
  105. }
  106. /**
  107. * @return {?}
  108. */
  109. complete() {
  110. /*noop*/
  111. }
  112. }
  113. export { MiniState, MiniStore };
  114. //# sourceMappingURL=ngx-bootstrap-mini-ngrx.js.map