/** * @return {?} */ ngOnDestroy() { if (this._focusTrap) { this._focusTrap.destroy(); } this._animationStarted.complete(); this._animationEnd.complete(); }
terminate() { this._workers.forEach((w) => w.terminate()); this.messages$.complete(); this.errors$.complete(); this._workers = null; }
/** * Cleans up the DOM after closing. * @return {?} */ _finishDismiss() { this._overlayRef.dispose(); if (!this._onAction.closed) { this._onAction.complete(); } this._afterDismissed.next({ dismissedByAction: this._dismissedByAction }); this._afterDismissed.complete(); this._dismissedByAction = false; }
async dispose(): Promise<void> { this._filesDidChangeObserver.complete(); this._hgRepoStateDidChangeObserver.complete(); this._hgActiveBookmarkDidChangeObserver.complete(); this._hgBookmarksDidChangeObserver.complete(); if (this._hgDirWatcher != null) { this._hgDirWatcher.close(); this._hgDirWatcher = null; } await this._cleanUpWatchman(); }
/** * Marks the snackbar action clicked. * @return {?} */ dismissWithAction() { if (!this._onAction.closed) { this._dismissedByAction = true; this._onAction.next(); this._onAction.complete(); } }
waitsForPromise(async () => { const taskRunner = new dummy.TaskRunner(); const taskEvents = new Subject(); const task = taskFromObservable(taskEvents); spyOn(task, 'cancel'); spyOn(task, 'onDidComplete').andCallThrough(); spyOn(taskRunner, 'runTask').andReturn(task); const state = { activeTaskRunner: taskRunner, taskRunners: Immutable.List([taskRunner]), }; const taskMeta = dummy.createTask('test'); const output = runActions( [Actions.runTask({...taskMeta, taskRunner}, false)], state, ); expect(task.onDidComplete).toHaveBeenCalled(); taskEvents.complete(); const result = await output.toArray().toPromise(); expect(result.map(action => action.type).slice(-2)).toEqual([ Actions.TASK_STARTED, Actions.TASK_COMPLETED, ]); expect(task.cancel).not.toHaveBeenCalled(); });
describe('getShortHeadChangesFromStateStream', () => { const states = new Subject(); const shortHeadChangesStream = getShortHeadChangesFromStateStream(states); const shortHeadChanges: Array<RepositoryShortHeadChange> = []; shortHeadChangesStream.subscribe(change => shortHeadChanges.push(change)); states.next(getDummyBookShelfState()); const newActiveShortHead = 'foo_bar'; const newStateWithShortHeadChange = getDummyBookShelfState(); const newRepositoryState = newStateWithShortHeadChange.repositoryPathToState.get( DUMMY_REPO_PATH_1, ); nullthrows(newRepositoryState).activeShortHead = newActiveShortHead; states.next(newStateWithShortHeadChange); states.complete(); waitsFor(() => shortHeadChanges.length === 1); runs(() => { const {repositoryPath, activeShortHead} = shortHeadChanges[0]; expect(repositoryPath).toBe(DUMMY_REPO_PATH_1); expect(activeShortHead).toBe(newActiveShortHead); }); });
/** * @return {?} */ ngOnDestroy() { this._scroll.deregister(this); if (this._scrollListener) { this.getElementRef().nativeElement.removeEventListener('scroll', this._scrollListener); } this._elementScrolled.complete(); }
dispose() { this._providerToFileToMessages.clear(); this._fileToProviders.clear(); this._providerToProjectDiagnostics.clear(); this._fileChanges.complete(); this._projectChanges.complete(); this._allChanges.complete(); }
/** * @return {?} */ ngOnDestroy() { if (this._focusMonitor) { this._focusMonitor.stopMonitoring(this._elementRef); } if (this._parentMenu && this._parentMenu.removeItem) { this._parentMenu.removeItem(this); } this._hovered.complete(); }
/** * @return {?} */ ngOnDestroy() { // If this is the last tree node being destroyed, // clear out the reference to avoid leaking memory. if (CdkTreeNode.mostRecentTreeNode === this) { CdkTreeNode.mostRecentTreeNode = null; } this._destroyed.next(); this._destroyed.complete(); }
function runActions(actions: Array<Action>, initialState: AppState): ReplaySubject<Action> { const store = createMockStore(initialState); const input = new Subject(); const output = new ReplaySubject(); getRootEpic()(new ActionsObservable(input), store).subscribe(output); actions.forEach(input.next.bind(input)); input.complete(); return output; }
waitsForPromise(async () => { const source = new Subject(); const diffsPromise = diffSets(source).toArray().toPromise(); source.next(new Set([1, 2])); source.next(new Set([1, 2, 3])); source.complete(); const diffs = await diffsPromise; expect(setsAreEqual(diffs[1].added, new Set([3]))).toBe(true); });
dispose(): void { for (const [filePath, buffer] of this._buffers.entries()) { this._emitClose(filePath, buffer); buffer.destroy(); } this._buffers.clear(); this._resources.dispose(); this._fileEvents.complete(); this._directoryEvents.complete(); }
waitsForPromise(async () => { const source = new Subject(); const diffsPromise = diffSets(source).toArray().toPromise(); source.next(new Set([1, 2, 3])); source.next(new Set([1, 2, 3])); source.complete(); const diffs = await diffsPromise; // Make sure we only get one diff (from the implicit initial empty set). expect(diffs.length).toBe(1); });
waitsForPromise(async () => { const source = new Subject(); const diffsPromise = diffSets(source).toArray().toPromise(); source.next(new Set([1, 2, 3])); source.complete(); const diffs = await diffsPromise; expect(diffs.length).toBe(1); expect(diffsAreEqual(diffs[0], { added: new Set([1, 2, 3]), removed: new Set(), })).toBe(true); });
/** * @return {?} */ ngOnDestroy() { this._nodeOutlet.viewContainer.clear(); this._onDestroy.next(); this._onDestroy.complete(); if (this._dataSource && typeof ((/** @type {?} */ (this._dataSource))).disconnect === 'function') { ((/** @type {?} */ (this.dataSource))).disconnect(this); } if (this._dataSubscription) { this._dataSubscription.unsubscribe(); this._dataSubscription = null; } }
async function getStateAfterActions( actions: Array<Action>, initialState?: AppState = createEmptyAppState(), ): Promise<AppState> { const actionStream = new Subject(); const states = createStateStream(actionStream, initialState); const statePromise = states.toPromise(); actions.forEach(action => { actionStream.next(action); }); actionStream.complete(); return await statePromise; }