Skip to content

Latest commit

 

History

History
34 lines (23 loc) · 832 Bytes

update.md

File metadata and controls

34 lines (23 loc) · 832 Bytes

Update

Updates are functions that enable simple transformations of elements. An update is triggered via dispatching of actions.

register(kind, actionType, fn)

Registers an update to a specific kind and action type.

Usage

import { update } from '@skele/classic'

update.register(['scene', 'article'], 'toggleIsBookmarked', el =>
  el.set('isBookmarked', !el.get('isBookmarked'))
)

forKind(kind, registrationFn)

Registers updates to a specific kind using a registration function.

Usage

import { update } from '@skele/classic'

update.forKind(['scene', 'article', 'briefing'], updates => {
  updates.register('toggleIsBookmarked', el =>
    el.set('bookmarked', !el.get('bookmarked'))
  )
  updates.register('toggleIsRead', el => el.set('isRead', !el.get('isRead')))
})