<commit_before>const create = require(`yolk-virtual-dom/create-element`)
const wrapObject = require(`./wrapObject`)
const addProperties = require(`./addProperties`)
const YolkBaseComponent = require(`./YolkBaseComponent`)
const CompositePropSubject = require(`./CompositePropSubject`)

function YolkCustomComponent () {}

YolkCustomComponent.prototype = {
  type: `Widget`,
  onMount () {},
  onUpdate () {},
  onUnmount () {},

  _initialize (props, children) {
    this._props = props
    this._props$ = null

    switch (children.length) {
    case 1:
      this._child = children[0]
      break
    case 0:
      this._child = new YolkBaseComponent(`div`)
      break
    default:
      throw new Error(`${this.constructor.name} may not have more than one child`)
    }
  },

  init () {
    this._props$ = new CompositePropSubject(this._props)

    const node = create(this._child)
    const props$ = wrapObject(this._props$.asSubjectObject())
    const mountDisposable = props$.take(1).subscribe(props => this.onMount(props, node))
    const updateDisposable = props$.skip(1).subscribe(props => this.onUpdate(props, node))

    this._onDestroy = () => {
      mountDisposable.dispose()
      updateDisposable.dispose()
    }

    return node
  },

  update (previous) {
    this._props$ = previous._props$<commit_msg>Transfer ownership of _onDestroy attribute on update<commit_after>const create = require(`yolk-virtual-dom/create-element`)
const wrapObject = require(`./wrapObject`)
const addProperties = require(`./addProperties`)
const YolkBaseComponent = require(`./YolkBaseComponent`)
const CompositePropSubject = require(`./CompositePropSubject`)

function YolkCustomComponent () {}

YolkCustomComponent.prototype = {
  type: `Widget`,
  onMount () {},
  onUpdate () {},
  onUnmount () {},

  _initialize (props, children) {
    this._props = props
    this._props$ = null

    switch (children.length) {
    case 1:
      this._child = children[0]
      break
    case 0:
      this._child = new YolkBaseComponent(`div`)
      break
    default:
      throw new Error(`${this.constructor.name} may not have more than one child`)
    }
  },

  init () {
    this._props$ = new CompositePropSubject(this._props)

    const node = create(this._child)
    const props$ = wrapObject(this._props$.asSubjectObject())
    const mountDisposable = props$.take(1).subscribe(props => this.onMount(props, node))
    const updateDisposable = props$.skip(1).subscribe(props => this.onUpdate(props, node))

    this._onDestroy = () => {
      mountDisposable.dispose()
      updateDisposable.dispose()
    }

    return node
  },

  update (previous) {
    this._onDestroy = previous._onDestroy
    this._props$ = previous._props$
{'fraction_non_alphanumeric': 0.13164649798313163, 'fraction_numerical': 0.003667033370003667, 'mean_word_length': 3.5618729096989967, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '5494749', 'n_tokens_mistral': 814, 'n_tokens_neox': 787, 'n_words': 173}