@stemy/ngx-utils 19.9.38 → 19.9.39

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.
@@ -762,7 +762,7 @@ class StateService {
762
762
  return this.router.config;
763
763
  }
764
764
  get $observable() {
765
- return this.$snapshot.pipe(skipWhile(snapshot => snapshot === emptySnapshot), debounceTime(25));
765
+ return this.$snapshot.pipe(skipWhile(snapshot => snapshot === emptySnapshot), debounceTime(10));
766
766
  }
767
767
  constructor(injector, zone, universal, router = null, contexts = null) {
768
768
  this.injector = injector;
@@ -2761,62 +2761,6 @@ function diffEntities(current, incoming) {
2761
2761
  };
2762
2762
  }
2763
2763
 
2764
- class TimerUtils {
2765
- static createTimeout(func, time) {
2766
- // @dynamic
2767
- const run = (timer) => {
2768
- timer.clear();
2769
- // If the time is zero or less, we run the function immediately because setTimeout puts it into the next "frame"
2770
- if (timer.time <= 0) {
2771
- timer.func();
2772
- return;
2773
- }
2774
- timer.id = setTimeout(() => {
2775
- timer.id = null;
2776
- timer.func();
2777
- }, timer.time);
2778
- };
2779
- // @dynamic
2780
- const clear = (timer) => {
2781
- if (!timer.id)
2782
- return;
2783
- clearTimeout(timer.id);
2784
- timer.id = null;
2785
- };
2786
- return TimerUtils.createTimer(run, clear, func, time);
2787
- }
2788
- static createInterval(func, time) {
2789
- // @dynamic
2790
- const run = (timer) => {
2791
- timer.clear();
2792
- timer.id = setInterval(timer.func, Math.max(timer.time, 5));
2793
- };
2794
- // @dynamic
2795
- const clear = (timer) => {
2796
- if (!timer.id)
2797
- return;
2798
- clearInterval(timer.id);
2799
- timer.id = null;
2800
- };
2801
- return TimerUtils.createTimer(run, clear, func, time);
2802
- }
2803
- static createTimer(run, clear, func, time) {
2804
- const timer = {};
2805
- const setParams = (func, time) => {
2806
- timer.func = !ObjectUtils.isFunction(func) ? (() => { }) : func;
2807
- timer.time = !ObjectUtils.isNumber(time) ? 100 : time;
2808
- };
2809
- timer.run = () => run(timer);
2810
- timer.clear = () => clear(timer);
2811
- timer.set = (func, time) => {
2812
- setParams(func, time);
2813
- timer.run();
2814
- };
2815
- setParams(func, time);
2816
- return timer;
2817
- }
2818
- }
2819
-
2820
2764
  class ObservableUtils {
2821
2765
  static toSearch(search) {
2822
2766
  return mergeMap(
@@ -2839,20 +2783,24 @@ class ObservableUtils {
2839
2783
  static subscribe(...subscribers) {
2840
2784
  const subscriptions = [];
2841
2785
  subscribers.forEach(info => {
2786
+ const timeout = info.timeout ?? 15;
2842
2787
  let alreadyCalled = false;
2843
- const timer = TimerUtils.createTimeout();
2844
2788
  info.subjects.forEach(subject => {
2845
- const ss = subject.subscribe((value) => {
2789
+ const ss = subject
2790
+ .pipe(map(v => {
2846
2791
  alreadyCalled = true;
2847
- timer.set(() => {
2848
- info.cb(subject, value);
2849
- }, info.timeout ?? 0);
2792
+ return v;
2793
+ }), debounceTime(timeout))
2794
+ .subscribe((value) => {
2795
+ info.cb(subject, value);
2850
2796
  });
2851
2797
  subscriptions.push(ss);
2852
2798
  });
2853
- if (alreadyCalled)
2854
- return;
2855
- info.cb();
2799
+ setTimeout(() => {
2800
+ if (alreadyCalled)
2801
+ return;
2802
+ info.cb();
2803
+ }, timeout);
2856
2804
  });
2857
2805
  return ObservableUtils.multiSubscription(...subscriptions);
2858
2806
  }
@@ -3171,6 +3119,62 @@ class SocketClient {
3171
3119
  }
3172
3120
  }
3173
3121
 
3122
+ class TimerUtils {
3123
+ static createTimeout(func, time) {
3124
+ // @dynamic
3125
+ const run = (timer) => {
3126
+ timer.clear();
3127
+ // If the time is zero or less, we run the function immediately because setTimeout puts it into the next "frame"
3128
+ if (timer.time <= 0) {
3129
+ timer.func();
3130
+ return;
3131
+ }
3132
+ timer.id = setTimeout(() => {
3133
+ timer.id = null;
3134
+ timer.func();
3135
+ }, timer.time);
3136
+ };
3137
+ // @dynamic
3138
+ const clear = (timer) => {
3139
+ if (!timer.id)
3140
+ return;
3141
+ clearTimeout(timer.id);
3142
+ timer.id = null;
3143
+ };
3144
+ return TimerUtils.createTimer(run, clear, func, time);
3145
+ }
3146
+ static createInterval(func, time) {
3147
+ // @dynamic
3148
+ const run = (timer) => {
3149
+ timer.clear();
3150
+ timer.id = setInterval(timer.func, Math.max(timer.time, 5));
3151
+ };
3152
+ // @dynamic
3153
+ const clear = (timer) => {
3154
+ if (!timer.id)
3155
+ return;
3156
+ clearInterval(timer.id);
3157
+ timer.id = null;
3158
+ };
3159
+ return TimerUtils.createTimer(run, clear, func, time);
3160
+ }
3161
+ static createTimer(run, clear, func, time) {
3162
+ const timer = {};
3163
+ const setParams = (func, time) => {
3164
+ timer.func = !ObjectUtils.isFunction(func) ? (() => { }) : func;
3165
+ timer.time = !ObjectUtils.isNumber(time) ? 100 : time;
3166
+ };
3167
+ timer.run = () => run(timer);
3168
+ timer.clear = () => clear(timer);
3169
+ timer.set = (func, time) => {
3170
+ setParams(func, time);
3171
+ timer.run();
3172
+ };
3173
+ setParams(func, time);
3174
+ return timer;
3175
+ }
3176
+ }
3177
+
3174
3178
  class UniqueUtils {
3175
3179
  static uuid() {
3176
3180
  if (typeof window !== "undefined" && typeof window.crypto !== "undefined" && typeof window.crypto.getRandomValues !== "undefined") {