Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Observable((observer: Observer): TeardownLogic => {
const unsubscribe$ = new Subject();
const deliveryError$ = new Subject();
// Wait until the message is delivered.
merge(this._brokerGateway.message$, deliveryError$)
.pipe(
filterByTopic(messageId),
first(),
timeoutWith(new Date(Date.now() + this._config.deliveryTimeout), throwError(`[MessageDispatchError] Broker did not report message delivery state within the ${this._config.deliveryTimeout}ms timeout. [message=${JSON.stringify(envelope)}]`)),
takeUntil(merge(this._destroy$, unsubscribe$)),
mergeMap(statusMessage => statusMessage.body.ok ? EMPTY : throwError(statusMessage.body.details)),
)
.subscribe(observer); // dispatch next, error and complete
// Dispatch the message to the broker.
this._brokerGateway.postMessage(envelope).catch(error => deliveryError$.error(error));
return (): void => unsubscribe$.next();
showRawMessage: false,
currentModuleStatus: undefined
};
this.baseState = this.state;
this.columnDefs = [
{
...rulesColumnDefs.ruleName,
cellRendererFramework: undefined // Don't allow soft select from an open flyout
},
rulesColumnDefs.severity,
rulesColumnDefs.alertStatus,
rulesColumnDefs.explore
];
this.resetTelemetry$ = new Subject();
this.telemetryRefresh$ = new Subject();
if (this.props.moduleStatus) {
this.state = {
...this.state,
currentModuleStatus: this.props.moduleStatus
};
} else {
this.props.fetchModules(this.props.device.id);
}
}
export const createSuggestionFetcher = (
first = 5,
requestGraphQL: PlatformContext['requestGraphQL']
): ((input: SuggestionInput) => void) => {
const fetcher = new Subject()
fetcher
.pipe(
distinctUntilChanged(),
debounceTime(200),
switchMap(({ query, handler }) =>
fetchSuggestions(query, first, requestGraphQL).pipe(
take(first),
map(createSuggestion),
// createSuggestion will return null if we get a type we don't recognize
filter((f): f is Suggestion => !!f),
toArray(),
map((suggestions: Suggestion[]) => ({
suggestions,
suggestHandler: handler,
})),
function manageEveryBuffers(
bufferType : IBufferType,
basePeriod : Period
) : Observable {
// Each Period for which there is currently a Buffer, chronologically
const periodList = new SortedList((a, b) => a.start - b.start);
const destroyBuffers$ = new Subject();
let hasLoadedABuffer = false; // true after the first PeriodBuffer is ready
/**
* @param {Object} period
* @returns {Observable}
*/
function launchConsecutiveBuffersForPeriod(
period : Period
) : Observable {
return manageConsecutivePeriodBuffers(bufferType, period, destroyBuffers$).pipe(
tap((message) => {
if (message.type === "periodBufferReady") {
if (!hasLoadedABuffer) {
hasLoadedABuffer = true;
}
periodList.add(message.value.period);
function makeD2StoresService(): D2StoreServiceType {
let _stores: D2Store[] = [];
// A subject that keeps track of the current account. Because it's a
// behavior subject, any new subscriber will always see its last
// value.
const accountStream = new BehaviorSubject(null);
// The triggering observable for force-reloading stores.
const forceReloadTrigger = new Subject();
// A stream of stores that switches on account changes and supports reloading.
// This is a ConnectableObservable that must be connected to start.
const storesStream = accountStream.pipe(
// Only emit when the account changes
distinctUntilChanged(compareAccounts),
// But also re-emit the current value of the account stream
// whenever the force reload triggers
merge(forceReloadTrigger.pipe(switchMap(() => accountStream.pipe(take(1))))),
// Whenever either trigger happens, load stores
switchMap(loadingTracker.trackPromise(loadStores)),
// Keep track of the last value for new subscribers
publishReplay(1)
) as ConnectableObservable;
// TODO: If we can make the store structures immutable, we could use
export class HotkeysService implements IService {
private _logger: Toolkit.Logger = new Toolkit.Logger('HotkeysService');
private _subscriptions: { [key: string]: Toolkit.Subscription | Subscription } = {};
private _dialogGuid: string = Toolkit.guid();
private _paused: boolean = false;
private _input: boolean = false;
private _subjects = {
newTab: new Subject(),
closeTab: new Subject(),
openTextFile: new Subject(),
openDltFile: new Subject(),
focusSearchInput: new Subject(),
openSearchFiltersTab: new Subject(),
selectNextRow: new Subject(),
selectPrevRow: new Subject(),
focusMainView: new Subject(),
focusSearchView: new Subject(),
showHotkeysMapDialog: new Subject(),
sidebarToggle: new Subject(),
toolbarToggle: new Subject(),
recentFiles: new Subject(),
recentFilters: new Subject(),
};
constructor() {
}
public init(): Promise {
return new Promise((resolve) => {
it('should pump values to multiple subscribers', (done: MochaDone) => {
const subject = new Subject();
const expected = ['foo', 'bar'];
let i = 0;
let j = 0;
subject.subscribe(function (x) {
expect(x).to.equal(expected[i++]);
});
subject.subscribe(function (x) {
expect(x).to.equal(expected[j++]);
}, null, done);
subject.next('foo');
subject.next('bar');
subject.complete();
parent: DockDef.Container | null;
}
interface IContainerData {
target: DockDef.Container;
parent: DockDef.Container | null;
key: string;
}
export class DocksService {
private _subjects = {
dock: new Subject(),
resized: new Subject(),
moved: new Subject(),
resizeStarted: new Subject(),
resizeFinished: new Subject(),
dragStarted: new Subject(),
dragFinished: new Subject(),
dragOver: new Subject(),
dragDrop: new Subject(),
};
private _dock: DockDef.Container;
private _sessionId: string = '';
constructor(sessionId: string, dock: DockDef.Container) {
this._sessionId = sessionId;
this._dock = dock;
}
public destroy() {
}
get(obj, key) {
return obj[key] ? obj[key] : obj[key] = new Subject()
}
})
constructor() {
this._hash = {};
this._index = rbush(16, [".lon", ".lat", ".lon", ".lat"]);
this._indexChanged$ = new Subject();
this._updated$ = new Subject();
}