pickadate.js
  • Documentation
  • Discussions
  • GitHub
  • v3 Docs

›API

Getting Started

  • Introduction
  • Installation
  • Usage

Bindings

  • Plain JavaScript
  • React DOM
  • React Native
  • jQuery

Guides

  • Using Translations
  • Creating Custom Actors
  • Upgrading from v3

API

  • The State Object
  • The Picker Object
  • The Store Object
  • The Translation Object

The Store Object

The store object provides methods to manage some state. You can trigger actions on the store to update the state as needed.

For a full reference on the state of the picker, read the API of the State Object.

Methods

addActor

ArgumentsReturns
ActorAction

Adds an actor to generate an action with the ability to update the store's state.

An "actor" is a method that receives the current state and a payload and then returns the next partial state to be applied.

An "action" is the method invoked with the payload which then triggers the "actor" with the current state.

const myStringActor = (state, payload) => {
  if (typeof payload.value === 'string') {
    return {
      someStateKey: payload.value,
    }
  }
}
const myStringAction = store.addActor(myStringActor)

With myStringAction above, it can be triggered it like this:

myStringAction({ value: 'cool' })

...to update the state's someStateKey value to 'cool'.

subscribe

ArgumentsReturns
callback: Functionunsubscribe: Function

Subscribes to updates to the state.

The function returned can be called to unsubscribe to the updates.

const callback = () => {
  console.log('The state was changed!')
}
const unsubscribe = store.subscribe(callback)

getState

ArgumentsReturns
noneObject

Gets the current state of the picker.

const state = picker.getState()
console.log(state) // '[object Object]'
← The Picker ObjectThe Translation Object →
  • Methods
    • addActor
    • subscribe
    • getState
pickadate.js
Documentation
Getting StartedJavaScriptReact DOMReact NativejQuery
Community
Stack OverflowSpectrum
More
GitHubStar
Copyright © 2012-2019 Amsul and the pickadate.js documentation authors.