Changelog
effector 21.8.0
sample({
clock: clickValidate,
source: $formFields,
target: [validateForm, sendStatsFx],
})
split
. Case functions and stores will choose target case by its name, matcher stores are boolean stores which indicate whether to choose given caseconst source = createEvent()
const even = createEvent()
const $odd = createStore(0)
split({
source,
// case function
match(n) {
if (n % 2 === 0) return 'even'
return 'odd'
},
cases: {
even,
odd: $odd,
},
})
const $currentPage = createStore('dashboard')
split({
source,
// case store
match: $currentPage,
cases: {
dashboard: even,
__: odd,
},
})
const tryUpdatePage = createEvent()
const updatePageFx = createEffect()
const $hasWriteAccess = createStore(false)
split({
source: tryUpdatePage,
match: {
// matcher store
admin: $hasWriteAccess,
},
cases: {
admin: updatePageFx,
},
})
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,
},
)
sample
with clock
without source
. For example, it useful in cases when clock
is array of units and no source
stores is neededsample({
clock: [fx1.doneData, fx2.doneData],
fn: data => ({url: '/stats', data})
target: fetchFx,
})
clock
to guard
to improve developer expirience in cases when update trigger (clock
field) and data source (source
field) are different thingsguard({
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