diff --git a/src/shared/modules/dbMeta/dbMetaDuck.js b/src/shared/modules/dbMeta/dbMetaDuck.js index 2bf95f686fa..9161f06136c 100644 --- a/src/shared/modules/dbMeta/dbMetaDuck.js +++ b/src/shared/modules/dbMeta/dbMetaDuck.js @@ -45,6 +45,7 @@ export const UPDATE_SERVER = 'meta/UPDATE_SERVER' export const UPDATE_SETTINGS = 'meta/UPDATE_SETTINGS' export const CLEAR = 'meta/CLEAR' export const FORCE_FETCH = 'meta/FORCE_FETCH' +export const DB_META_DONE = 'meta/DB_META_DONE' /** * Selectors @@ -292,6 +293,8 @@ export const dbMetaEpic = (some$, store) => return ( Rx.Observable.timer(1, 20000) .merge(some$.ofType(FORCE_FETCH)) + // Throw away newly initiated calls until done + .throttle(() => some$.ofType(DB_META_DONE)) // Labels, types and propertyKeys .mergeMap(() => Rx.Observable.fromPromise( @@ -342,7 +345,7 @@ export const dbMetaEpic = (some$, store) => .filter(connectionLossFilter) .merge(some$.ofType(DISCONNECTION_SUCCESS)) ) - .mapTo({ type: 'NOOP' }) + .mapTo({ type: DB_META_DONE }) ) }) diff --git a/src/shared/modules/jmx/jmxDuck.js b/src/shared/modules/jmx/jmxDuck.js index ce9999246c1..07b4d599eb4 100644 --- a/src/shared/modules/jmx/jmxDuck.js +++ b/src/shared/modules/jmx/jmxDuck.js @@ -41,6 +41,7 @@ import { getBackgroundTxMetadata } from 'shared/services/bolt/txMetadata' export const NAME = 'jmx' export const UPDATE = NAME + '/UPDATE' export const UPDATE_JMX_VALUES = NAME + '/UPDATE_JMX_VALUES' +export const UPDATE_JMX_VALUES_DONE = NAME + '/UPDATE_JMX_VALUES_DONE' /** * Selectors @@ -140,20 +141,24 @@ export const jmxEpic = (some$, store) => .filter(s => s.state === CONNECTED_STATE) .merge(some$.ofType(CONNECTION_SUCCESS)) .mergeMap(() => { - return Rx.Observable.timer(0, 20000) - .merge(some$.ofType(FORCE_FETCH)) - .mergeMap(() => - Rx.Observable.fromPromise(fetchJmxValues(store)).catch(() => - Rx.Observable.of([]) + return ( + Rx.Observable.timer(0, 20000) + .merge(some$.ofType(FORCE_FETCH)) + // Throw away new calls until we're finished + .throttle(() => some$.ofType(UPDATE_JMX_VALUES_DONE)) + .mergeMap(() => + Rx.Observable.fromPromise(fetchJmxValues(store)).catch(() => + Rx.Observable.of([]) + ) ) - ) - .filter(r => r) - .do(res => store.dispatch(updateJmxValues(res))) - .takeUntil( - some$ - .ofType(LOST_CONNECTION) - .filter(connectionLossFilter) - .merge(some$.ofType(DISCONNECTION_SUCCESS)) - ) - .mapTo({ type: 'NOOP' }) + .filter(r => r) + .do(res => store.dispatch(updateJmxValues(res))) + .takeUntil( + some$ + .ofType(LOST_CONNECTION) + .filter(connectionLossFilter) + .merge(some$.ofType(DISCONNECTION_SUCCESS)) + ) + .mapTo({ type: UPDATE_JMX_VALUES_DONE }) + ) })