github effector/effector effector@21.8.0
effector 21.8.0

latest releases: effector@23.4.4, effector@23.4.3, effector@23.4.2...
4 years ago
  • Add type support for arrays in sample target (PR #284, #445)
sample({
  clock: clickValidate,
  source: $formFields,
  target: [validateForm, sendStatsFx],
})
  • Add support for case functions, case stores and matcher stores to split. Case functions and stores will choose target case by its name, matcher stores are boolean stores which indicate whether to choose given case
const source = createEvent()
const even = createEvent()
const odd = createStore(0)

split({
  source,
  // matcher function
  match(n) {
    if (n % 2 === 0) return 'even'
    return 'odd'
  },
  cases: {
    even,
    odd,
  }
})

const $currentPage = createStore('dashboard')

split({
  source,
  // matcher store
  match: $currentPage,
  cases: {
    dashboard: even,
    __: odd,
  }
})

const tryUpdatePage = createEvent()
const updatePageFx = createEffect()



const $hasWriteAccess = createStore(false)


split({
  source: tryUpdatePage,
  match: {
    // case store
    admin: $hasWriteAccess
  },
  cases: {
    admin: updatePageFx,
  }
})
  • Add updateFilter config field to createStore to skip arbitrary store updates (discussion #428)
const $playerPosition = createStore({x: 0, y: 0}, {
  updateFilter: (update, current) => update.x !== current.x
})
  • Add support for sample with clock without source. For example, it useful in cases when clock is array of units and no source stores is needed
sample({
  clock: [fx1.doneData, fx2.doneData],
  fn: data => ({url: '/stats', data})
  target: fetchFx,
})
  • Add support for clock to guard to improve developer expirience in cases when update trigger (clock field) and data source (source field) are different things
guard({
  clock: validateForm,
  source: $formFields,
  filter: formFields => validator(formFields),
  target: submitFormFx,
})
  • Add addNames field to babel plugin (PR #450)

  • Add type support for Scope to clearNode (issue #441)

  • Add compositeName to Domain typings, making it consistent with other units

  • Add EventPayload and UnitValue type helpers (PR #434)

  • Improve various edge cases with fork api and serialization

  • Improve typechecking for attach (issue #439)

  • Fix various type issues in sample and guard typings

Don't miss a new effector release

NewReleases is sending notifications on new releases.