Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
import { observable, action } from 'xmobx/mobx'
import { IncrementerProps, DefaultIncrementerState } from './typings'

class IncrementerState implements DefaultIncrementerState {
  @observable count: number
  @observable shouldIncrement: boolean = true
  @observable shouldDecrement: boolean = false

  @action.bound
  incrementCount(props: IncrementerProps) {
    const { maxValue, step } = props

    if (this.count < maxValue) {
      this.count += step
      this.shouldDecrement = true
    }

    if (this.count === maxValue) {
      this.shouldIncrement = false
    }
  }

  @action.bound
  decrementCount(props: IncrementerProps) {
    const { step } = props

    if (this.count > 1) {
      this.count -= step
      this.shouldIncrement = true
    }

    if (this.count === 1) {
      this.shouldDecrement = false
    }
  }
}

export { IncrementerState }