consumeProvider(provider: T): IDisposable {
   this._providerRegistry.addProvider(provider);
   this._newProviderEvents.next();
   return new Disposable(() => {
     this._providerRegistry.removeProvider(provider);
   });
 }
Example #2
0
 setState(newState: Object): void {
   const nextState = {
     ...this.state,
     ...newState,
   };
   this._states.next(nextState);
 }
 _displayMessage(message: string): IDisposable {
   const {busy, done} = this._nextMessagePair(message);
   this._messages.next(busy);
   return new Disposable(() => {
     this._messages.next(done);
   });
 }
Example #4
0
 this._fileDoesNotExistExceptionSet.forEach(path => {
     this._subject.next({
         kind: 'error',
         description: 'doesNotExist',
         path,
     });
 });
Example #5
0
 this._fileAlreadyExistExceptionSet.forEach(path => {
     this._subject.next({
         kind: 'error',
         description: 'alreadyExist',
         path,
     });
 });
Example #6
0
 /**
  * Does some manual dirty checking on the native input `value` property.
  * @return {?}
  */
 _dirtyCheckNativeValue() {
     const /** @type {?} */ newValue = this.value;
     if (this._previousNativeValue !== newValue) {
         this._previousNativeValue = newValue;
         this.stateChanges.next();
     }
 }
Example #7
0
        constructor(props: PropsTypeIn) {
            super(props);

            type PropsSubscribeType = {
                props: PropsTypeOut,
                mounted: bool
            };

            const newProps$: Observable<PropsTypeOut> = mapProps(this.receive$.asObservable())
                .distinctUntilChanged(isEqualProps);

            const mounted$: Observable<bool> = this.mounted$.startWith(false);

            this.subscription = newProps$
                .withLatestFrom(mounted$, (props: PropsTypeOut, mounted: bool): PropsSubscribeType => ({
                      props,
                      mounted
                }))
                .subscribe((propsSubscribe: PropsSubscribeType) => {
                    this.innerProps = propsSubscribe.props;

                    if (propsSubscribe.mounted) {
                        this.forceUpdate();
                    }
                });

            this.receive$.next(this.props);
        }
Example #8
0
		function dataCallback(data) {
			data_line += data;
			if (data_line[data_line.length-1] == '\n') {
				consoleListener.next(data_line);
				data_line = '';
			}
		}
Example #9
0
            worker.onmessage = (m) => {
                this.messages$.next({tid: worker.tid, m});

                worker.tid = null;

                this._run();
            };
Example #10
0
    it('renders while waiting for values', () => {
      // TODO: Remove in favor of startWith operator.
      const StartWith = () => null
      const asyncVal = new Subject()

      const WithObservables = withObservables(
        () => ({
          asyncVal,
        }),
        {startWith: StartWith}
      )(Child)

      const wrapper = mount(<WithObservables />)

      expect(wrapper.find('StartWith')).toHaveLength(1)
      expect(wrapper.find('Child')).toHaveLength(0)

      asyncVal.next(1)
      wrapper.update()
      expect(wrapper.find('StartWith')).toHaveLength(0)
      expect(wrapper.find('Child')).toHaveLength(1)

      wrapper.setProps({})
      expect(wrapper.find('StartWith')).toHaveLength(1)
      expect(wrapper.find('Child')).toHaveLength(0)
    })
Example #11
0
 /**
  * Handles lifecycle messages from stderr, exit, and error streams,
  * responding by logging and staging for process restart.
  */
 _onProcessMessage(message: ProcessMessage): void {
   switch (message.kind) {
     case 'stdout':
       break;
     case 'stderr':
       logger.warn(
         `${this._name} - error from stderr received: `,
         message.data.toString(),
       );
       break;
     case 'exit':
       logger.error(
         `${this._name} - exited with ${exitEventToMessage(message)}`,
       );
       this._exitMessage.next(message);
       this.dispose();
       break;
     default:
       // This case should never be reached.
       invariant(
         false,
         `${this._name} - unknown message received: ${message}`,
       );
   }
 }
Example #12
0
 /**
  * Marks the snackbar action clicked.
  * @return {?}
  */
 dismissWithAction() {
     if (!this._onAction.closed) {
         this._dismissedByAction = true;
         this._onAction.next();
         this._onAction.complete();
     }
 }
Example #13
0
            worker.onerror = (e) => {
                this.errors$.next({tid: worker.tid, e});

                worker.tid = null;

                this._run();
            };
 setUser(user,push){
   this._loginState = 0;
   /*this.services.getService("http").setToken(user && user.access_token);*/
   
   if(user && user.profile){
     this._user = new User(user.access_token,user.scope,user.profile);
     if(push){
       this.userSubject.next(this._user);
       this.userReplay.next(this._user);
     };
   }
   else if(push){
     this.userSubject.next(null);
     this.userReplay.next(null);
   }
 }
Example #15
0
export function pipeProcessMessagesToConsole(
  processName: string,
  progressUpdates: Subject<Message>,
  showNotificationOnCompletion: boolean,
  processMessage: LegacyProcessMessage /* TODO(T17463635) */,
): void {
  switch (processMessage.kind) {
    case 'stderr':
      progressUpdates.next({text: processMessage.data, level: 'error'});
      break;

    case 'stdout':
      progressUpdates.next({text: processMessage.data, level: 'info'});
      break;

    case 'error':
      const {error} = processMessage;
      progressUpdates.next({
        text: error.message || String(error),
        level: 'error',
      });
      break;

    case 'exit':
      if (processMessage.exitCode === 0) {
        progressUpdates.next({
          text: `${processName} completed successfully`,
          level: 'success',
        });
        atom.notifications.addSuccess('Operation completed successfully', {
          detail: `${processName} finished`,
        });
      } else {
        progressUpdates.next({
          text: `${processName} exited with non zero code`,
          level: 'error',
        });
        if (showNotificationOnCompletion) {
          atom.notifications.addError('Operation Failed', {
            detail: 'Check console for output',
          });
        }
        dispatchConsoleToggle(true /* console visibility */);
      }
      break;
  }
}
Example #16
0
 }), operators_1.concatMap(() => {
     if (this._dryRun) {
         return rxjs_1.of();
     }
     this._lifeCycle.next({ kind: 'post-tasks-start' });
     return this._engine.executePostTasks()
         .pipe(operators_1.tap({ complete: () => this._lifeCycle.next({ kind: 'post-tasks-end' }) }), operators_1.defaultIfEmpty(), operators_1.last());
 }), operators_1.tap({ complete: () => {
Example #17
0
 /**
  * Removes an item from the menu.
  * \@docs-private
  * @param {?} item
  * @return {?}
  */
 removeItem(item) {
     /** @type {?} */
     const index = this._items.indexOf(item);
     if (this._items.indexOf(item) > -1) {
         this._items.splice(index, 1);
         this._itemChanges.next(this._items);
     }
 }
Example #18
0
 _open(filePath: NuclideUri, contents: string, changeCount: number): void {
   // We never call setPath on these TextBuffers as that will
   // start the TextBuffer attempting to sync with the file system.
   const newBuffer = new TextBuffer(contents);
   newBuffer.changeCount = changeCount;
   this._buffers.set(filePath, newBuffer);
   this._fileEvents.next(createOpenEvent(this.createFileVersion(filePath, changeCount), contents));
 }
Example #19
0
 endExternalEditor(error, result) {
   this.rl.resume();
   if (error) {
     this.editorResult.error(error);
   } else {
     this.editorResult.next(result);
   }
 }
Example #20
0
 _sendConsoleMessage(level: string, text: string): void {
   this._consoleEvent$.next(
     JSON.stringify({
       level,
       text,
     }),
   );
 }
Example #21
0
  it('should not store stale events when everyone is unsubscribed', () => {
    const arr1 = [];
    const arr2 = [];

    input.next(0);
    const sub1 = subscribeArray(arr1);
    input.next(1);
    sub1.unsubscribe();

    input.next(2);

    const sub2 = subscribeArray(arr2);
    input.next(3);
    sub2.unsubscribe();

    expect(arr1).toEqual([1]);
    expect(arr2).toEqual([3]);
  });
Example #22
0
 /**
  * @param {?} value
  * @return {?}
  */
 set disabled(value) {
     this._disabled = coerceBooleanProperty(value);
     // Browsers may not fire the blur event if the input is disabled too quickly.
     // Reset from here to ensure that the element doesn't become stuck.
     if (this.focused) {
         this.focused = false;
         this.stateChanges.next();
     }
 }
 /**
  * Creates a new {\@link MockConnection}. This is equivalent to calling `new
  * MockConnection()`, except that it also will emit the new `Connection` to the `connections`
  * emitter of this `MockBackend` instance. This method will usually only be used by tests
  * against the framework itself, not by end-users.
  * @param {?} req
  * @return {?}
  */
 createConnection(req) {
     if (!req || !(req instanceof Request)) {
         throw new Error(`createConnection requires an instance of Request, got ${req}`);
     }
     /** @type {?} */
     const connection = new MockConnection(req);
     this.connections.next(connection);
     return connection;
 }
Example #24
0
 register(platformProvider: PlatformProvider): Disposable {
   this._registeredProviders.push(platformProvider);
   this._providersChanged.next();
   return new Disposable(() => {
     const index = this._registeredProviders.indexOf(platformProvider);
     this._registeredProviders.splice(index, 1);
     this._providersChanged.next();
   });
 }
Example #25
0
 // Add the specified value to the counter's count.
 async addCount(x: number): Promise<void> {
   // Broadcast an event.
   this._changes.next({
     type: 'add',
     oldValue: this._count,
     newValue: this._count + x,
   });
   this._count += x;
 }
Example #26
0
 async _checkConflictChange(): Promise<void> {
   await this._updateStateFilesExistence();
   if (this._isInConflict) {
     if (!this._isRebasing) {
       this._isInConflict = false;
       this._hgConflictStateDidChangeObserver.next(false);
     }
     return;
   }
   // Detect if we are not in a conflict.
   if (!this._lockFileHeld && this._isRebasing) {
     const mergeConflicts = await this.fetchMergeConflicts();
     if (mergeConflicts.length > 0) {
       this._isInConflict = true;
       this._hgConflictStateDidChangeObserver.next(true);
     }
   }
 }
Example #27
0
 /**
  * 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;
 }
Example #28
0
  registerWidget(WidgetApp, regionName) {
    if (!Array.isArray(this.widgetsByRegion[regionName])) {
      this.widgetsByRegion[regionName] = [];
    }

    this.widgetsByRegion[regionName].push(WidgetApp);

    return this.widgetsSubject.next(this.widgetsByRegion);
  }
Example #29
0
    tasks.switchMap(async task => {
        if (isExecuting){
            lastTask = task;
            return;
        }
            
        isExecuting = true;

        let result = await task();
        finished.next(result);

        while (lastTask != null){
            const toRun = lastTask;
            lastTask = null;
            result = await toRun();
            finished.next(result);
        }
    })
Example #30
0
 /**
  * @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();
 }