module.exports = function ({target, store, component, diff, options, raf}) {
  raf = raf != null ? raf : window.requestAnimationFrame

  if (options != null) {
    options.dispatch = dispatch
    options.next = next
  } else {
    options = {dispatch, next}
  }

  let stores = !Array.isArray(store) ? [store] : store
  let state = stores.reduce((state, store) => store(state))
  let rafCalled = false

  return function (init) {
    init({target, dispatch})
  }

  function dispatch () {
    state = stores.reduce((state, store) => {
      const args = (arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments))

      args.unshift(state)

      return store.apply(null, args)
    }, state)

    if (!rafCalled) {
      rafCalled = true

      raf(render)
    }
  }

  function render () {
    rafCalled = false

    let app = {state}

    Object.keys(options).forEach(function (prop) {
      app[prop] = options[prop]
    })

    const element = component(app)

    if (element != null) {
      diff(target, element)
    }
  }

  function next (callback) {
    process.nextTick(callback, {target, dispatch})
  }
}

module.exports = function ({target, store, component, diff, raf}) {
  raf = raf != null ? raf : window.requestAnimationFrame

  let state = store()
  let rafCalled = false

  return function (init) {
    init({target, dispatch})
  }

  function dispatch () {
    const args = (arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments))

    args.unshift(state)

    state = store.apply(null, args)

    if (!rafCalled) {
      rafCalled = true

      raf(render)
    }
  }

  function render () {
    rafCalled = false

    const element = component({state, dispatch, next})

    if (element != null) {
      diff(target, element)
    }
  }

  function next (callback) {
    process.nextTick(callback, {target, dispatch})
  }
}

Remove features added in last version
Remove features added in last version
