<commit_before>import { Observable } from 'rx';
import * as wx from 'webrx';

import { BaseViewModel } from '../../React/BaseViewModel';

export class ModalDialogViewModel extends BaseViewModel {
  public static displayName = 'ModalDialogViewModel';

  public isVisible: wx.IObservableProperty<boolean> = null;

  public show: wx.ICommand<any>;
  public hide: wx.ICommand<any>;

  constructor(isVisible = false) {
    super();

    this.show = wx.command();
    this.hide = wx.command();

    this.isVisible = Observable
      .merge(this.show.results.map(x => true), this.hide.results.map(x => false))
      .startWith(isVisible)
      .toProperty();
  }

  public hideOnExecute<T>(command: wx.ICommand<T>) {
    this.subscribe(
      command.results.invokeCommand(this.hide)
    );

    return command;
  }
};<commit_msg>adding patch to modal dialog component to prevent null ref access of a command in hideOnExecute function<commit_after>import { Observable } from 'rx';
import * as wx from 'webrx';

import { BaseViewModel } from '../../React/BaseViewModel';

export class ModalDialogViewModel extends BaseViewModel {
  public static displayName = 'ModalDialogViewModel';

  public isVisible: wx.IObservableProperty<boolean> = null;

  public show: wx.ICommand<any>;
  public hide: wx.ICommand<any>;

  constructor(isVisible = false) {
    super();

    this.show = wx.command();
    this.hide = wx.command();

    this.isVisible = Observable
      .merge(this.show.results.map(x => true), this.hide.results.map(x => false))
      .startWith(isVisible)
      .toProperty();
  }

  public hideOnExecute<T>(command: wx.ICommand<T>) {
    if (command != null) {
      this.subscribe(
        command.results.invokeCommand(this.hide)
      );
    }
    else {
      this.logger.warn('hideOnExecute called with null command');
    }

    return command;
  }
};
{'fraction_non_alphanumeric': 0.1307154384077461, 'fraction_numerical': 0.0, 'mean_word_length': 3.439140811455847, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5393076', 'n_tokens_mistral': 572, 'n_tokens_neox': 559, 'n_words': 133}