Bulk Updating
In addition to allowing for inline updating, violet-paginator also exposes functions that can update every item within the list. This might be handy when implementing something like an inbox where you want to mark all messages as read or important. As with single item updating, bulk updating has both an immediate and an asynchronous version.
Async update
updateItemsAsync(itemIds, data, update)
Similar to updateAsync, but accepts a list of ids instead of a single id.
- Call updateItemsto merge the properties from thedataargument into each specified item.
- Call updatingItemsto indicate that all specified items are waiting for an update from the server.
- Call the updatepromise, provided as the last argument toupdateItemsAsync.
- If the updatepromise fails, useresetResultsto revert the result list to its previous state. Then dispatchmarkItemsErroredto indicate that the items failed to update.
Example:
import api from 'ROOT/api'
import { composables } from 'violet-paginator'
import * as actionTypes from './actionTypes'
const pageActions = composables({ listId: 'recipes' })
export function markAllRead(messageIds) {
  const data = {
    read: true
  }
  return pageActions.updateItemsAsync(
    messageIds,
    data,
    api.messages.markAllRead(messageIds, data)
  )
}
Instant Update
updateItems(itemIds, data)
Use the updateItems action to instantly apply the provided data to the items specified by the itemIds. Example:
import { composables } from 'violet-paginator'
const pageActions = composables({ listId: 'recipes' })
export function toggleRead(recipeIds) {
  return pageActions.updateAll(
    recipeIds,
    { active: !recipe.get('active') }
  )
}