effector-vue
Advanced tools
Changelog
effector 22.0.0
attach({source, async effect(source, params) {}})
const scope = fork()
Unit not found in scope
error is no longer exists, any unit could be used in any scopefork
and serialize
a hundredfoldfork({values: [[$user, 'alice'], [$age, 22]]})
serialize: 'ignore'
option to createStore
to declare store as ignored by serialize
callsonlyChanges: true
a default serialize
optioncombine
arguments and throw an error in case of undefined
and non-store units (issue #509)createStoreObject
alias for combine
effector/fork
module.thru
store.map
.on
in derived stores created by store.map
and combine
event.map
, event.filterMap
and event.filter
fx.done
, fx.doneData
and other events belongs to effectsɔ
(latin small letter open o) symbol to prevent incorrect unicode parsingscope.find
which is a wrong abstraction for a new forkScope
a unit:
Scope
to is.unit
is.scope
methodscopeBind(unit, {scope})
, which is also can be used outside from .watch
Changelog
effector-react 21.1.0
useEvent
. It's a shorthand for calling several useEvent
at once (PR #425 by @sergeysova)export function ExampleComponent() {
const handlers = useEvent({emailChanged, passwordChanged})
return (
<div>
<input onChange={handlers.emailChanged} />
<input onChange={handlers.passwordChanged} />
</div>
)
}
export function ExampleComponent() {
const [changeEmail, changePassword] = useEvent([
emailChanged,
passwordChanged,
])
return (
<div>
<input onChange={changeEmail} />
<input onChange={changePassword} />
</div>
)
}
Changelog
effector 21.0.3, effector-react 21.0.4, effector-vue 21.0.3
Changelog
effector 21.0.0
split
for pattern-matching without additional forwardsimport {split, createEffect, createEvent} from 'effector'
const messageReceived = createEvent()
const showTextPopup = createEvent()
const playAudio = createEvent()
const reportUnknownMessageTypeFx = createEffect({
handler({type}) {
console.log('unknown message:', type)
},
})
split({
source: messageReceived,
match: {
text: msg => msg.type === 'text',
audio: msg => msg.type === 'audio',
},
cases: {
text: showTextPopup,
audio: playAudio,
__: reportUnknownMessageTypeFx,
},
})
showTextPopup.watch(({value}) => {
console.log('new message:', value)
})
messageReceived({
type: 'text',
value: 'Hello',
})
// => new message: Hello
messageReceived({
type: 'image',
imageUrl: '...',
})
// => unknown message: image
You can match directly to store api as well:
import {split, createStore, createEvent, createApi} from 'effector'
const messageReceived = createEvent()
const $textContent = createStore([])
split({
source: messageReceived,
match: {
text: msg => msg.type === 'text',
audio: msg => msg.type === 'audio',
},
cases: createApi($textContent, {
text: (list, {value}) => [...list, value],
audio: (list, {duration}) => [...list, `audio ${duration} ms`],
__: list => [...list, 'unknown message'],
}),
})
$textContent.watch(messages => {
console.log(messages)
})
messageReceived({
type: 'text',
value: 'Hello',
})
// => ['Hello']
messageReceived({
type: 'image',
imageUrl: '...',
})
// => ['Hello', 'unknown message']
messageReceived({
type: 'audio',
duration: 500,
})
// => ['Hello', 'unknown message', 'audio 500 ms']
effector/fork
into effector
. Now all methods required for SSR are exported from the library itself, making effector/fork
an aliasScope
type alias for Fork
import {createStore} from 'effector/effector.mjs'
console.error
with undefined return, which was violating the type of effectrestore
aliases, event.filter(fn)
alias for event.filterMap(fn)
, greedy
in sample
as separate last argument and unused blocks
and Kind