Example #1
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);
        }
 AutofillMonitor.prototype.monitor = /**
  * Monitor for changes in the autofill state of the given input element.
  * @param {?} element The element to monitor.
  * @return {?} A stream of autofill state changes.
  */
 function (element) {
     var _this = this;
     if (!this._platform.isBrowser) {
         return EMPTY;
     }
     var /** @type {?} */ info = this._monitoredElements.get(element);
     if (info) {
         return info.subject.asObservable();
     }
     var /** @type {?} */ result = new Subject();
     var /** @type {?} */ listener = function (event) {
         if (event.animationName === 'cdk-text-field-autofill-start') {
             element.classList.add('cdk-text-field-autofilled');
             _this._ngZone.run(function () { return result.next({ target: /** @type {?} */ (event.target), isAutofilled: true }); });
         }
         else if (event.animationName === 'cdk-text-field-autofill-end') {
             element.classList.remove('cdk-text-field-autofilled');
             _this._ngZone.run(function () { return result.next({ target: /** @type {?} */ (event.target), isAutofilled: false }); });
         }
     };
     this._ngZone.runOutsideAngular(function () {
         element.addEventListener('animationstart', listener, listenerOptions);
         element.classList.add('cdk-text-field-autofill-monitored');
     });
     this._monitoredElements.set(element, {
         subject: result,
         unlisten: function () {
             element.removeEventListener('animationstart', listener, listenerOptions);
         }
     });
     return result.asObservable();
 };
Example #3
0
 constructor(host, force = false) {
     super(typeof host == 'string'
         ? new core_1.virtualFs.ScopedHost(new node_1.NodeJsSyncHost(), core_1.normalize(host))
         : host, force);
     this._subject = new rxjs_1.Subject();
     this._fileDoesNotExistExceptionSet = new Set();
     this._fileAlreadyExistExceptionSet = new Set();
     this.reporter = this._subject.asObservable();
 }
Example #4
0
  constructor(rawState: ?Object) {
    const action$ = new Rx.Subject();
    const initialState = deserializeAppState(rawState);
    this._state$ = new Rx.BehaviorSubject(initialState);
    createStateStream(
      action$.asObservable(),
      initialState,
    )
      .sampleTime(100)
      .subscribe(this._state$);
    this._commands = new Commands(
      action$,
      () => this._state$.getValue(),
    );
    this._outputService = new OutputService(this._commands);
    this._disposables = new CompositeDisposable(
      atom.contextMenu.add({
        '.nuclide-console-record': [
          {
            label: 'Copy Message',
            command: 'nuclide-console:copy-message',
          },
        ],
      }),
      atom.commands.add(
        '.nuclide-console-record',
        'nuclide-console:copy-message',
        event => {
          const el = event.target;
          if (el == null || el.innerText == null) {
            return;
          }
          atom.clipboard.write(el.innerText);
        },
      ),
      featureConfig.observe(
        'nuclide-console.maximumMessageCount',
        maxMessageCount => this._commands.setMaxMessageCount(maxMessageCount),
      ),

      // Action side-effects
      new DisposableSubscription(
        action$.subscribe(action => {
          if (action.type !== ActionTypes.EXECUTE) {
            return;
          }
          const {executorId, code} = action.payload;
          const executors = this._state$.getValue().executors;
          const executor = executors.get(executorId);
          invariant(executor);
          executor.execute(code);
        })
      ),
    );
  }
Example #5
0
 _watch(path, options) {
     path = this._toAbsolute(path);
     const subject = new rxjs_1.Subject();
     let maybeWatcherArray = this._watchers.get(path);
     if (!maybeWatcherArray) {
         maybeWatcherArray = [];
         this._watchers.set(path, maybeWatcherArray);
     }
     maybeWatcherArray.push([options || {}, subject]);
     return subject.asObservable();
 }
Example #6
0
 constructor(props) {
   super(props);
   const { vis } = props;
   this.appState = vis.API.getAppState();
   this.state = {
     model: props.visParams,
     dirty: false,
     autoApply: true,
     visFields: props.visFields
   };
   this.onBrush = brushHandler(props.vis.API.timeFilter);
   this.visDataSubject = new Rx.Subject();
   this.visData$ = this.visDataSubject.asObservable().pipe(share());
 }
Example #7
0
 AutofillMonitor.prototype.monitor = /**
  * @param {?} elementOrRef
  * @return {?}
  */
 function (elementOrRef) {
     var _this = this;
     if (!this._platform.isBrowser) {
         return EMPTY;
     }
     /** @type {?} */
     var element = elementOrRef instanceof ElementRef ? elementOrRef.nativeElement : elementOrRef;
     /** @type {?} */
     var info = this._monitoredElements.get(element);
     if (info) {
         return info.subject.asObservable();
     }
     /** @type {?} */
     var result = new Subject();
     /** @type {?} */
     var cssClass = 'cdk-text-field-autofilled';
     /** @type {?} */
     var listener = /** @type {?} */ ((function (event) {
         // Animation events fire on initial element render, we check for the presence of the autofill
         // CSS class to make sure this is a real change in state, not just the initial render before
         // we fire off events.
         if (event.animationName === 'cdk-text-field-autofill-start' &&
             !element.classList.contains(cssClass)) {
             element.classList.add(cssClass);
             _this._ngZone.run(function () { return result.next({ target: /** @type {?} */ (event.target), isAutofilled: true }); });
         }
         else if (event.animationName === 'cdk-text-field-autofill-end' &&
             element.classList.contains(cssClass)) {
             element.classList.remove(cssClass);
             _this._ngZone.run(function () { return result.next({ target: /** @type {?} */ (event.target), isAutofilled: false }); });
         }
     }));
     this._ngZone.runOutsideAngular(function () {
         element.addEventListener('animationstart', listener, listenerOptions);
         element.classList.add('cdk-text-field-autofill-monitored');
     });
     this._monitoredElements.set(element, {
         subject: result,
         unlisten: function () {
             element.removeEventListener('animationstart', listener, listenerOptions);
         }
     });
     return result.asObservable();
 };
Example #8
0
export function consumeRegisterExecutor(
  registerExecutor: RegisterExecutorFunction,
): void {
  invariant(disposables != null);
  const messages: Subject<{result?: Object}> = new Subject();
  disposables.add(
    registerExecutor({
      id: 'echo',
      name: 'Echo',
      send(code: string): void {
        messages.next({
          level: 'log',
          data: {
            value: code,
            type: 'text',
          },
        });
      },
      output: messages.asObservable(),
    }),
  );
}
Example #9
0
 /**
  * Gets an observable that is notified when the snack bar action is called.
  * @return {?}
  */
 onAction() {
     return this._onAction.asObservable();
 }
Example #10
0
 /**
  * Gets an observable that is notified when the snack bar is finished closing.
  * @return {?}
  */
 afterDismissed() {
     return this._afterDismissed.asObservable();
 }
Example #11
0
 get channels() {
     return this.channelsSubject.asObservable();
 }
Example #12
0
export function getServerStatusUpdates(): Observable<ServerStatusUpdate> {
  return serverStatusUpdates.asObservable();
}
Example #13
0
 getEventObservable(): Observable<Array<mixed>> {
   return this._executionEvent$.asObservable();
 }
Example #14
0
 get lifeCycle() {
     return this._lifeCycle.asObservable();
 }
 //Get user once
 getUser(){
   return this.userSubject.asObservable().take(1);
 }
Example #16
0
 get onIdChange() {
     return this.idSubject.asObservable();
 }
Example #17
0
 getWritten$() {
   return this._written$.asObservable();
 }
Example #18
0
 /**
  * Returns observable that emits when a scroll event is fired on the host element.
  * @return {?}
  */
 elementScrolled() {
     return this._elementScrolled.asObservable();
 }
Example #19
0
 get messageFromStream() {
     return this.streamSubject.asObservable();
 }
Example #20
0
 getInvalidations(): Observable<DiagnosticInvalidationMessage> {
   return this._invalidations.asObservable();
 }
Example #21
0
 getUpdates(): Observable<DiagnosticProviderUpdate> {
   return this._updates.asObservable();
 }
Example #22
0
export function getErrors(): Observable<mixed> {
  return errors.asObservable();
}
Example #23
0
 get reporter() {
     return this._reporter.asObservable();
 }
 return new rxjs_1.Observable(subject => {
     // Handle input.
     inboundBus.subscribe(message => {
         switch (message.kind) {
             case api_1.JobInboundMessageKind.Ping:
                 subject.next({ kind: api_1.JobOutboundMessageKind.Pong, description, id: message.id });
                 break;
             case api_1.JobInboundMessageKind.Stop:
                 // There's no way to cancel a promise or a synchronous function, but we do cancel
                 // observables where possible.
                 if (subscription) {
                     subscription.unsubscribe();
                 }
                 subject.next({ kind: api_1.JobOutboundMessageKind.End, description });
                 subject.complete();
                 // Close all channels.
                 channels.forEach(x => x.complete());
                 break;
             case api_1.JobInboundMessageKind.Input:
                 inputChannel.next(message.value);
                 break;
         }
     });
     // Configure a logger to pass in as additional context.
     const logger = new index_2.Logger('job');
     logger.subscribe(entry => {
         subject.next({
             kind: api_1.JobOutboundMessageKind.Log,
             description,
             entry,
         });
     });
     // Execute the function with the additional context.
     subject.next({ kind: api_1.JobOutboundMessageKind.Start, description });
     const channels = new Map();
     const newContext = Object.assign({}, context, { input: inputChannel.asObservable(), logger,
         createChannel(name) {
             if (channels.has(name)) {
                 throw new ChannelAlreadyExistException(name);
             }
             const channelSubject = new rxjs_1.Subject();
             channelSubject.subscribe(message => {
                 subject.next({
                     kind: api_1.JobOutboundMessageKind.ChannelMessage, description, name, message,
                 });
             }, error => {
                 subject.next({ kind: api_1.JobOutboundMessageKind.ChannelError, description, name, error });
                 // This can be reopened.
                 channels.delete(name);
             }, () => {
                 subject.next({ kind: api_1.JobOutboundMessageKind.ChannelComplete, description, name });
                 // This can be reopened.
                 channels.delete(name);
             });
             channels.set(name, channelSubject);
             return channelSubject;
         } });
     const result = fn(argument, newContext);
     // If the result is a promise, simply wait for it to complete before reporting the result.
     if (index_3.isPromise(result)) {
         result.then(result => {
             subject.next({ kind: api_1.JobOutboundMessageKind.Output, description, value: result });
             subject.next({ kind: api_1.JobOutboundMessageKind.End, description });
             subject.complete();
         }, err => subject.error(err));
     }
     else if (rxjs_1.isObservable(result)) {
         subscription = result.subscribe((value) => subject.next({ kind: api_1.JobOutboundMessageKind.Output, description, value }), error => subject.error(error), () => {
             subject.next({ kind: api_1.JobOutboundMessageKind.End, description });
             subject.complete();
         });
         return subscription;
     }
     else {
         // If it's a scalar value, report it synchronously.
         subject.next({ kind: api_1.JobOutboundMessageKind.Output, description, value: result });
         subject.next({ kind: api_1.JobOutboundMessageKind.End, description });
         subject.complete();
     }
 });