<commit_before>'use strict';

import * as React from 'react';
import * as Rx from 'rx';
import * as wx from 'webrx';

import logManager from '../App/Logging';
import { IBaseViewModel } from './BaseViewModel';

export interface IBaseViewProps {
  key?: string | number;
  viewModel: IBaseViewModel;
}

export abstract class BaseView<TViewProps extends IBaseViewProps, TViewModel extends IBaseViewModel> extends React.Component<TViewProps, TViewModel> {
  public static displayName = 'BaseView';

  private updateSubscription: Rx.IDisposable;

  protected logger = logManager.getLogger(this.getDisplayName());

  constructor(props?: TViewProps, context?: any) {
    super(props, context);

    this.state = props.viewModel as TViewModel;
  }

  protected updateOn(): Rx.Observable<any>[] { return []; }

  protected getDisplayName() { return Object.getName(this); }
  protected getRateLimit() { return 100; }

  protected renderView() { this.forceUpdate(); }

  protected initialize() {}
  protected cleanup() {}

  public bindText(propertySelector: (viewModel: TViewModel) => wx.IObservableProperty<string>) {
    return (x: any) => {
      let value = (x.target as React.HTMLAttributes).value;
      propertySelector(this.state)(value);
      this.forceUpdate();
    }
  }

  public bindObservable<TResult>(commandSelector: (viewModel: TViewModel) => wx.ICommand<TResult>, observable: Rx.Observable<TResult>) {
    return this.state.bind(observable, commandSelector(this.state));
  }

  public bindCallback<TParameter>(<commit_msg>HTMLAttributes.value is now typed as string | string[].  we will assume usage of bindText assumes a string and therefore cast it appropriately.<commit_after>'use strict';

import * as React from 'react';
import * as Rx from 'rx';
import * as wx from 'webrx';

import logManager from '../App/Logging';
import { IBaseViewModel } from './BaseViewModel';

export interface IBaseViewProps {
  key?: string | number;
  viewModel: IBaseViewModel;
}

export abstract class BaseView<TViewProps extends IBaseViewProps, TViewModel extends IBaseViewModel> extends React.Component<TViewProps, TViewModel> {
  public static displayName = 'BaseView';

  private updateSubscription: Rx.IDisposable;

  protected logger = logManager.getLogger(this.getDisplayName());

  constructor(props?: TViewProps, context?: any) {
    super(props, context);

    this.state = props.viewModel as TViewModel;
  }

  protected updateOn(): Rx.Observable<any>[] { return []; }

  protected getDisplayName() { return Object.getName(this); }
  protected getRateLimit() { return 100; }

  protected renderView() { this.forceUpdate(); }

  protected initialize() {}
  protected cleanup() {}

  public bindText(propertySelector: (viewModel: TViewModel) => wx.IObservableProperty<string>) {
    return (x: any) => {
      let value = (x.target as React.HTMLAttributes).value;
      propertySelector(this.state)(value as string);
      this.forceUpdate();
    }
  }

  public bindObservable<TResult>(commandSelector: (viewModel: TViewModel) => wx.ICommand<TResult>, observable: Rx.Observable<TResult>) {
    return this.state.bind(observable, commandSelector(this.state));
  }

  public bindCallback<TParameter>(
{'fraction_non_alphanumeric': 0.12117426608369769, 'fraction_numerical': 0.0018738288569643974, 'mean_word_length': 4.844890510948905, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 25, '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': '7228434', 'n_tokens_mistral': 950, 'n_tokens_neox': 896, 'n_words': 243}