push()

in packages/core/src/models/History.ts [52:72]


  push(type?: string) {
    if (this.locking) return
    if (this.current < this.history.length - 1) {
      this.history = this.history.slice(0, this.current + 1)
    }
    const item = {
      data: this.context.serialize(),
      timestamp: Date.now(),
      type,
    }
    this.current = this.history.length
    this.history.push(item)
    const overSizeCount = this.history.length - this.maxSize
    if (overSizeCount > 0) {
      this.history.splice(0, overSizeCount)
      this.current = this.history.length - 1
    }
    if (this.props?.onPush) {
      this.props.onPush(item)
    }
  }