Recent Releases of effector
effector - effector 23.4.1
- Fix sample name support for cases without plugin
- TypeScript
Published by zerobias 8 months ago
effector - effector Atlas 23.4.0
Babel/SWC plugin
- Add support for hmr. Big thanks to @movpushmov and @kireevmp
- Add support for transformLegacyDomainMethods option (PR #1059)
- Add forceScope option (PR #1002)
- Add effector-action to default factories
- Add support for tagged template factories (like patronum format)
Typings
- Improve
splittypings (PR #1253), fixes issues #622 #769 and #999. Big thanks to @den-churbanov for handling these insurmountable typings 💪 - Add
skipVoidto type ofdomain.createStore(PR #1262)
Runtime
- Add better support for
namefield insamplefor improvedpatronum.debug({trace: true})logs (issue #1268)
- TypeScript
Published by zerobias 8 months ago
effector - effector 23.3.0
- Improve error messages: now errors for
skipVoidandstore without sidwill point to the line of store creation. This will help locate troublesome units easily - Add support for multiple arguments to
scopeBind. This feature indirectly allows to use multiple arguments inreflect(issue reflect#91) - Fix issues with
clearNode(issue #1200)
- TypeScript
Published by zerobias about 1 year ago
effector - effector-react 23.3.0
- Add react 19 support
- TypeScript
Published by zerobias about 1 year ago
effector - effector-vue 23.1.0
- Update useVModel bindings (issue #1150)
- Add support for options api for vue 3 (useful for large codebase migration from vue 2) (issue #1178)
Big thanks to egoson for making this release possible
- TypeScript
Published by zerobias over 1 year ago
effector - effector 23.2.3
- Fix types for
attach({ effect }), allowing to pass explicitnamein this overload (issue #1000)
- TypeScript
Published by zerobias over 1 year ago
effector - effector 23.2.2
- Fix types for createEffect and attach in factories with generics (issue #1069). Cases like this now works correctly:
ts
function createModel<T>() {
const $data = createStore<T | null>(null)
const fx = createEffect(() => null as T)
sample({clock: fx.doneData, target: $data})
}
- TypeScript
Published by zerobias almost 2 years ago
effector - effector-react 23.2.1
- Fix types for
useUnit([fx])with effect with custom error (PR #1070)
- TypeScript
Published by zerobias almost 2 years ago
effector - effector 23.2.1
- Fix forbidden keys in combine (issue #1064)
- TypeScript
Published by zerobias almost 2 years ago
effector - effector-react 23.2.0
- Make
Gate.openandGate.closeEventCallableto allow users to call it in tests
- TypeScript
Published by zerobias about 2 years ago
effector - effector 23.2.0
- Improve type validation for derived stores in fork
- Add missed runtime validation for
allSettledcalls with derived units. This case was labeled as a type error, but was forgotten in runtime.
- TypeScript
Published by zerobias about 2 years ago
effector - effector 23.1.0
- Support arbitary callbacks in scopeBind. Allows library developers to create better APIs in a way that is Fork API - compatible. https://github.com/effector/effector/pull/1029
- Remove deprecated types for already removed $store.map overload. https://github.com/effector/effector/pull/1029
- TypeScript
Published by AlexandrHoroshih about 2 years ago
effector - effector-react 23.1.0
- Skip enumerable prototype-inherited properties in useUnit(shape). Some badly-written polyfills might add such properties to built-ins like Array. https://github.com/effector/effector/pull/1023
- Add missing depreaction tag to the one of useEvent overloads. https://github.com/effector/effector/pull/1030
- Add
useProvidedScopelow level API for library developers. https://github.com/effector/effector/pull/1033
- TypeScript
Published by AlexandrHoroshih about 2 years ago
effector - effector-react 23.0.1
- Fix warning about
useStoreappeared inuseList(PR #1022)
- TypeScript
Published by zerobias about 2 years ago
effector - effector Spacewatch 23.0.0
Improvements
- Introduce
EventCallable,StoreWritableandUnitTargetabletypes to allow users to express and understand what could be updated or called directly and what could not. NowcreateStorereturnsStoreWritablewhich can be passed to sample target andcombinereturnsStorewhich will show type and runtime error (PR #966) - Improve error messages: now it includes unit names and locations so it will be useful to find errors in raw server logs or bundles with disabled source maps. To enable locations in errors use
addLoc: truein babel-plugin. Usually the one wanted to enable this in development only soaddLocplugin option is disabled by default (PR #1015) - Add
batchoption tocreateWatch(PR #850) - Add
@withease/factoriesto babel-plugin defaults (PR #995) - Add all
patronummodules to babel-plugin defaults (PR #996) - Rename
greedytobatchinsample.greedy: truebecomesbatch: falsewhich is a better mental model for what this option do (PR #972) - Unify programmatic sid insertion in
mergeandrestore(PR #969) - Allow
domainto be used inattachwithout parent effect (PR #895)
Bug fixes
- Fix nullable type of
.reinit, now it exists inStoreWritableand not exists inStore(PR #966) - Fix serialization of ignored stores (PR #903)
- Fix race condition in parallel effect calls (PR #849)
- Fix scope reading its initial values from current (not initial) store value (PR #909)
- Fix duplicated
combinecalls (PR #916) - Fix reading stale value in
attach(PR #1011)
Deprecations and removed apis
- Deprecate undefined as magical value to skip store updates, use
skipVoid: trueoption incombineandmapto enable old behavior. Getting rid of that edge case will allow to introduce lazy computations (issue #920) - Deprecate
forwardandguardin favor ofsample(PR #913) - Deprecate
reactSsroption in babel-plugin (PR #910) - Deprecate
onlyChangesoption inserialize(PR #907) - Deprecate raw object
{[fx.sid]: Function}in forkhandlers(PR #973) - Deprecate
.watchwith second argument in favor ofsample(PR #906) - Deprecate
.getType()- relic from ancient times which exists for redux compatibility (PR #899) - Deprecate
effector/babel-plugin-react(PR #948) - Deprecate
fork(domain)andhydrate(domain)- this api existed for traking units in scopes when Fork API was introduced, but starting from 22 version this is done automatically and domain is no longer required for that (PR #950)
- Throw error when unit called from a pure function (PR #905)
- Throw error when derived event is called (PR #905)
- Throw error when
fnin$store.map(fn)returnsundefinedin the initialization (issue #828)
- Remove flow typings. In the beginning, the effector was written in flow, but now only types remained and they were extremely outdated due to lack of expertise in the technology. The flow community maintains bindings in a separate repository. (PR #912)
- Remove deprecated
effector/forkmodule (PR #842) - Remove deprecated
createStoreObjectalias forcombine(PR #908) - Remove deprecated
.thrumethod (PR #843) - Remove deprecated second argument with state from
$store.map(PR #846) - Remove deprecated
restore($store)support. This was an obscure feature when store is passed to method and returned without changes as is (PR #1018)
Performance
- 10% performance improvement (PR #1014)
See also our migration guide
- TypeScript
Published by zerobias over 2 years ago
effector - effector-react 23.0.0
- Deprecate
effector-react/scopein favor of isomorphic hooks (PR #979) - Deprecate
useStore,useEvent,connectandcreateStoreConsumerin favor of universaluseUnit(PR #951) - Deprecate
createComponentin favor of@effector/reflect - Remove deprecated
effector-react/ssrmodule (PR #844) - Remove deprecated createReactState and createContextComponent (PR #845)
- TypeScript
Published by zerobias over 2 years ago
effector - effector-vue 23.0.0
- Add
useUnithook (PR #1003) - Make bindings isomorphic
- Deprecate
effector-vue/ssrin favor of isomorphic hooks (PR #1005) - Remove obsolete deprecated apis
$watchAsStoreand$store(PR #1004)
- TypeScript
Published by zerobias over 2 years ago
effector - effector-solid 0.23.0
- Make all hooks isomorphic
- Deprecate
effector-solid/scopein favor of isomorphic hooks (PR #979)
- TypeScript
Published by zerobias over 2 years ago
effector - effector 22.8.8
- Add new types from effector 23: UnitTargetable, EventCallable and StoreWritable as aliases to improve migration experience and ecosystem compatibility (PR #1017)
- TypeScript
Published by zerobias over 2 years ago
effector - effector 22.8.7
- Fix
combinefunction called twice on firstallSettledcall (PR #984)
- TypeScript
Published by zerobias over 2 years ago
effector - effector-react 22.5.4
effector-react 22.5.4
Fix for createWatch implementation to improve @effector/next updates flow
- TypeScript
Published by AlexandrHoroshih over 2 years ago
effector - effector-react 22.5.3
- Fix too frequent
useUnitupdates (PR #904)
- TypeScript
Published by zerobias almost 3 years ago
effector - effector 22.8.6
- Follow-up fix for
22.8.2: nowcombinein tuple-form handles complex edge-cases with mapped stores correctly. (PR #902)
- TypeScript
Published by igorkamyshev almost 3 years ago
effector - effector-react 22.5.2
- Fix bug in
useUnitduring event change (issue #900, PR #901)
- TypeScript
Published by zerobias almost 3 years ago
effector - effector 22.8.5
- Follow up fix for
22.8.4: now fix works forfork({ handlers })calls too. PR #898
- TypeScript
Published by AlexandrHoroshih almost 3 years ago
effector - effector 22.8.4
Fixed an edge case for fork calls without sid (function from release 22.8.0). Some libraries provide built-in sid's in the code, which led to the duplicated sid found exception when calling fork when trying to use two instances of the same factory in a test and running it without effector/babel-plugin.
The exception on fork calls is no longer thrown, and all sid-related checks and assertions have been moved to serialize calls, since sid's are actually only required for serialize to work. PR #897
- TypeScript
Published by AlexandrHoroshih almost 3 years ago
effector - effector 22.8.3
- Added missing node and stateRef ids to meta-objects. These are internal changes which are not covered by the types or docs yet.
- TypeScript
Published by AlexandrHoroshih almost 3 years ago
effector - effector 22.8.2
combinetypes now allow primitive values, just like it was stated in the docs. Thanks to @faustienf 🎉 PR #884- Events, created from split with match-object shape and internal inFlight counters of Effects now have proper metadata to use in the Inspect API. PR #892
- TypeScript
Published by AlexandrHoroshih almost 3 years ago
effector - effector 22.8.1
- Internal state refs now also see meta, if owned by store. PR #889
- TypeScript
Published by AlexandrHoroshih almost 3 years ago
effector - effector 22.8.0
- Sids are no longer required for
fork({ values, handlers }), which allows to run tests withouteffector/babel-plugin. Note, that plugin and sids are still required for SSR. (PR #855)
- TypeScript
Published by AlexandrHoroshih almost 3 years ago
effector -
- Fix Gate usage as component.
<Gate />will also be isomorphic by scope.
- TypeScript
Published by AlexandrHoroshih almost 3 years ago
effector - effector 22.7.0
- Fix
Declarationtype, provide missing top-level properties forregionandfactorytypes - Add node's
idtoDeclarationtype
- TypeScript
Published by AlexandrHoroshih almost 3 years ago
effector - effector 22.6.2
- Fix return type of
withRegion
- TypeScript
Published by igorkamyshev almost 3 years ago
effector - effector 22.6.1
- Add missing
exportsdefinition foreffector/inspectAPI
- TypeScript
Published by AlexandrHoroshih almost 3 years ago
effector - effector 22.6.0
- Implemented inspect API (https://github.com/effector/effector/pull/859)
- TypeScript
Published by AlexandrHoroshih almost 3 years ago
effector - effector 22.5.2
- Fix
serialize: ignoreoncreateStoremust not serialize, eventfork({ values })is used for the store (PR #862)
- TypeScript
Published by sergeysova about 3 years ago
effector - effector 22.5.1
- Fix default factories list in babel-plugin (PR #857)
- TypeScript
Published by zerobias about 3 years ago
effector - effector-react 22.5.0
- Make
useGateisomorphic ineffector-reactmodule, so the one not needed to useeffector-react/scopeanymore (PR #852) - Fix
useUnithangs when scope is changed (happens when route is changed in next.js) (PR #851)
- TypeScript
Published by zerobias about 3 years ago
effector - effector 22.5.0
- Support
allSettled(scope)feature.
- TypeScript
Published by zerobias about 3 years ago
effector - effector-solid 0.22.7
- Support
@@unitShapeprotocol (PR #803) inuseUnit
- TypeScript
Published by igorkamyshev about 3 years ago
effector - effector-react 22.4.0
- Support
@@unitShapeprotocol (PR #803) inuseUnit
- TypeScript
Published by igorkamyshev about 3 years ago
effector - effector 22.4.1
- Add type support for read only arrays in sample
source. This case now supported and typechecked correctly:
```ts const profileFormSubmitted = createEvent() const $name = createStore('alice') const $age = createStore(0) const saveProfileFx = createEffect(async ([name, age]: [string, number]) => {})
sample({ clock: profileFormSubmitted, source: [$name, $age] as const, target: saveProfileFx, }) ```
Note that the one need to use "as const" in that case to got correct typechecking because without it typescript cannot infer the type [Store<string>, Store<number>]. We are working to avoid that limitation, stay tuned!
- TypeScript
Published by zerobias about 3 years ago
effector - effector Encke 22.4.0

- Add custom serializers for Store (PR #744)
- Allow to pass domain as an argument for createEvent and similar methods (PR #763)
- Add
$store.reinitevent to reset store to default value (PR #797)
Before $store.reinit:
```ts
const $formValues = createStore
sample({ clock: [timeoutOut, buttonClicked, meteorHit], target: [ saveAllStuffFx, ] })
// here we would need to duplicate the same clocks 👎 $formValues.reset([timeoutOut, buttonClicked, meteorHit]) ```
With $store.reinit:
```ts
const $formValues = createStore
sample({ clock: [timeoutOut, buttonClicked, meteorHit], target: [ saveAllStuffFx, // reset $formValues back to null due to one of the clock reasons $formValues.reinit, // no need to duplicate clocks list 👍 ] }) ```
- Add safe mode for scopeBind (PR #688)
- Add
is.attachedmethod to detect effects created viaattach(PR #670) - Add @farfetched/core and atomic-router to default factories so the one not needed to describe them explicitly
- Protect against combine argument being broken via Array.slice (PR #801)
- Add "type" entry for package exports (PR #759)
- Finally allow
Gateto be serialized (as this requires changes in babel plugin) (PR #683)
- TypeScript
Published by zerobias over 3 years ago
effector - effector-react 22.3.4
- Fixed
useUnitskipping updates when used withuseEffectanduseGate
- TypeScript
Published by zerobias over 3 years ago
effector - effector-react 22.3.3
- Fix
useUnitskipping updates during scope changes (often happens in next.js apps). Big thanks to @AlexandrHoroshih for investigation
- TypeScript
Published by zerobias over 3 years ago
effector - effector-react 22.3.1
- Fix
useUnitskipping updates in react 16-17
- TypeScript
Published by zerobias over 3 years ago
effector - effector-vue 22.2.0
- Add
useStoreMaphook for Vue 3 composition API to select part from a store (PR #780 by @ilajosmanov)
- TypeScript
Published by igorkamyshev over 3 years ago
effector - effector-react 22.3.0
- Made hooks
useEvent,useStore,useStoreMapanduseListisomorphic, now they would usescopefrom theProviderif it is available and scope-less mode otherwise. ForuseUnitit was done in 22.2.0. - Added parameter
forceScopetouseEvent,useStore,useStoreMapanduseListto force usage of scope fromProvider, it would throw an error ifProvideris not available,/scopemodule setsforceScopetotrueby default
- TypeScript
Published by igorkamyshev over 3 years ago
effector - effector-solid 0.22.6
- Add type of
Providerto main module
- TypeScript
Published by igorkamyshev over 3 years ago
effector - effector-solid 0.22.5
- Add export of
Providerfrom main module
- TypeScript
Published by igorkamyshev over 3 years ago
effector - effector-react 22.2.0
What's Changed
- Made hook
useUnitisomorphic, now it would usescopefrom theProviderif it is available and scope-less mode otherwise (PR #776 and PR #785) - Added parameter
forceScopeto all hooks to force usage of scope fromProvider, it would throw an error ifProvideris not available (PR #776 and PR #785),/scopemodule setsforceScopetotrueby default - Added "type" entry for package exports (PR #759)
- Fixed typing in
useUnit(PR #747)
New Contributors
- @sagdeev made their first contribution in https://github.com/effector/effector/pull/776
- @rachaeldawn made their first contribution in https://github.com/effector/effector/pull/759
- TypeScript
Published by igorkamyshev over 3 years ago
effector - effector-solid 0.22.4
What's New
- Made
useUnitisomorphic, now it would usescopefrom theProviderif it is available and scope-less mode otherwise (PR #782) - Added parameter
forceScopetouseUnitto force usage of scope fromProvider, it would throw an error ifProvideris not available (PR #782),/scopemodule setsforceScopetotrueby default
New Contributors
- @usmanyunusov made their first contribution in https://github.com/effector/effector/pull/782
- TypeScript
Published by igorkamyshev over 3 years ago
effector - effector-vue 22.1.2
Bug fixes
- Added "type" entry for package exports by @rachaeldawn (PR #759)
- TypeScript
Published by zerobias over 3 years ago
effector - effector-solid 0.22.3
Bug fixes
- Added "type" entry for package exports by @rachaeldawn (PR #759)
- TypeScript
Published by zerobias over 3 years ago
effector - forest 0.21.2
Bug fixes
- Added "type" entry for package exports by @rachaeldawn (PR #759)
- TypeScript
Published by zerobias over 3 years ago
effector - effector-react 22.1.6
Bug fixes
- Improve useUnit types by @Drevoed in #747
- TypeScript
Published by zerobias over 3 years ago
effector - effector-solid 0.22.2
Bug fixes
- Improve useUnit types by @Drevoed in #747
- TypeScript
Published by zerobias over 3 years ago
effector - effector-react@22.1.5
What's Changed
- Fix useUnit typings by @Drevoed in https://github.com/effector/effector/pull/741
Full Changelog: https://github.com/effector/effector/compare/effector-react@22.1.0...effector-react@22.1.1
- TypeScript
Published by sergeysova over 3 years ago
effector - effector-react 22.1.0
What's Changed
- Added support for react 18 (PR #655)
- Added
useUnitmethod to read multiple stores and bind events or effects to scope in a single batched call (PR #733, #738) ```tsx import {createEvent, createStore, fork} from 'effector' import {useUnit, Provider} from 'effector-react/scope'
const inc = createEvent() const $count = createStore(0) const $title = createStore('useStore example')
$count.on(inc, x => x + 1)
const App = () => { const [count, title, incFn] = useUnit([$count, $title, inc]) return ( <>
{title}
Count: {count}
</> ) }const scope = fork()
render(
() => (
- Added `placeholder` option to `useList` to render in cases of empty list
tsx
const ChatList = () => (
- Added `defaultValue` option to `useStoreMap` to return in cases when `fn` returns undefined
tsx
const ChatName = ({id}) => {
const chat = useStoreMap({
store: $chats,
keys: [id],
fn: (chats) => chats.find((chat) => chat.id === id),
defaultValue: {id: 'default', name: 'Default chat'},
})
return {chat.name}
}
``
- FixedGate.status` store being serialized (PR #683)
Documentation Updates
- Fix example of Gate usage in documentation by @7iomka in https://github.com/effector/effector/pull/669
- Rewrite API section in the usage with react by @sergeysova in https://github.com/effector/effector/pull/682
- docs: useUnit basic usage by @AlexandrHoroshih in https://github.com/effector/effector/pull/738
New Contributors
- @nonzzz made their first contribution in https://github.com/effector/effector/pull/663
- @7iomka made their first contribution in https://github.com/effector/effector/pull/669
- @yialo made their first contribution in https://github.com/effector/effector/pull/671
- @Drevoed made their first contribution in https://github.com/effector/effector/pull/685
- @lud made their first contribution in https://github.com/effector/effector/pull/715
- @xxxxue made their first contribution in https://github.com/effector/effector/pull/716
- @anatolykopyl made their first contribution in https://github.com/effector/effector/pull/724
- @ainursharaev made their first contribution in https://github.com/effector/effector/pull/730
Full Changelog: https://github.com/effector/effector/compare/effector@22.3.0...effector-react@22.1.0
- TypeScript
Published by sergeysova over 3 years ago
effector - effector 22.3.0
Features
- Added documentation for utility types https://github.com/effector/effector/commit/55d300d762c9104e22e138aed28e27c44a51cbf8
- Added new utility method
createWatchhttps://github.com/effector/effector/pull/646
New Contributors
- @VadimFilimonov made their first contribution in https://github.com/effector/effector/pull/653
- @cqh963852 made their first contribution in https://github.com/effector/effector/pull/657
- @sagdeev made their first contribution in https://github.com/effector/effector/pull/661
Full Changelog: https://github.com/effector/effector/compare/forest@0.21.1...effector@22.3.0
- TypeScript
Published by sergeysova almost 4 years ago
effector - forest 0.21.1
Bug fixes
Fixed bug with wrong behaviour of classList with static object values #649
- TypeScript
Published by sergeysova almost 4 years ago
effector - forest 0.21.0
Features
Added support for classList in h() and spec() #638
CSS classes can be merged and applied via multiple spec() calls:
ts
h('div', {
attr: { class: "basic" },
classList: ["another"],
fn() {
spec({ classList: { first: true, second: false } })
spec({ classList: ['second', 'third'] })
},
})
Result will be:
html
<div class="basic another first second third"></div>
- TypeScript
Published by sergeysova almost 4 years ago
effector - effector Halley 22.2.0
- Added
filteroption tosample, thereby makingguardan alias (issue #521)ts sample({ clock: submitPasswordEvent, source: $store, filter: (state: AuthFlowState) => state is WaitingPasswordState, fn: (waitingPasswordState, clock) => waitingPasswordState.password, target: submitPassowrdFx, }) - Added
clockoption tosplit(issue #537)ts split({ clock: submit, source: $form, match: $mode, cases: { draft: saveFormDraftFx, send: sendFormToBackendFx, } }) - Improved
sampletype checking:- Fixed cases when target units becomes compatible with any type (issue #600)
- Fixed cases when method call being marked as error when it perfectly correct
- Removed vague "incompatible unit in target" error
- Error messages now explicitly tells which type is given by source and which one is expected by target
- 16 overloads was merged into single one to improve clarity of error messages. Will remove a lot of noise from IDE output thereby improving developer expirience
- Improved
splittype checking:- Fixed a case when units in cases becomes compatible with any type
- Removed vague "incompatible unit in target" error
- Error messages now explicitly tells which type is given by source and which one is expected by failed target case
- Added jsdoc documentation for all top level methods. Will be used by IDE such as VS Code and Webstorm to provide better developer expirience
- Derived units in target of
sample,guard,splitandforwardare deprecated (issue #563) - Imperative calls of derived units created by
merge,sampleandsplitare deprecated - Imperative calls of events and effects in pure functions are deprecated (issue #541)
restore($store)is deprecated (issue #571)- Effects created by
attachgot correct name for use in developer tools like effector-logger (issue #527) - Fixed a case when
sample/guardpass obsolete data from it'ssourcestore (issue #544) - Fixed data race when using
combinewith fork api (issue #613) - Fixed cases when
effector/babel-pluginchanges function calls which it should avoid (issue #603) - Fixed support for multiple passes of
effector/babel-plugin(issue #601) - Fixed
combinesupport for units with large union types (issue #531) - Fixed support for calls without payload for
Event<unknown>(PR #454) - Fixed circular reference warning during import of typings (issue #578)
- TypeScript
Published by zerobias about 4 years ago
effector - effector-vue 22.1.0
New features
- Added support for Vue 3 SSR via new useEvent hook and VueSSRPlugin (PR #595)
- TypeScript
Published by zerobias about 4 years ago
effector - effector-react 22.0.6
Bugfixes
- Fix
Can't perform a React state update on an unmounted componentwarning foruseStoreMapin a few cases (issue #574)
- TypeScript
Published by zerobias about 4 years ago
effector - effector 22.1.2
- Allow to use
effector/babel-plugininpatronum/macrohttps://github.com/effector/effector/commit/68dffae660eea209de17e6d88b72edb7c82b87de
- TypeScript
Published by sergeysova over 4 years ago
effector - effector 22.1.1
- Fix data races that cause obsolete states to appear in the
.onand.resetmethods
- TypeScript
Published by zerobias over 4 years ago
effector - effector 22.1.0
- Added option
debugSidstoeffector/babel-plugin
The option allows adding file path and variable name to a sid for each unit definition. It allows to easily debug serialized scope using SSR.
- TypeScript
Published by sergeysova over 4 years ago
effector - effector 22
effector 22.0.0
- Add support for plain functions to attach:
attach({source, async effect(source, params) {}}) - Allow to use fork without domains:
const scope = fork()Unit not found in scopeerror is no longer exists, any unit could be used in any scope- Increase performance of
forkandserializea hundredfold
- Add support for attached effects to fork handlers
- Add support for tuples to fork values and handlers:
fork({values: [[$user, 'alice'], [$age, 22]]}) - Add
serialize: 'ignore'option tocreateStoreto declare store as ignored byserializecalls - Make
onlyChanges: truea defaultserializeoption - Fix babel plugin issue with parsing method calls (e.g. in react native)
- Validate
combinearguments and throw an error in case ofundefinedand non-store units (issue #509) - Throw an error when fork handlers or values got units without sid or with duplicate sid
- Deprecate
createStoreObjectalias forcombine - Deprecate
effector/forkmodule - Deprecate
.thru - Deprecate second argument in
store.map - Deprecate direct manipulations with derived units:
- Deprecate
.onin derived stores created bystore.mapandcombine - Deprecate calls of derived events created by
event.map,event.filterMapandevent.filter - Deprecate calls of
fx.done,fx.doneDataand other events belongs to effects
- Deprecate
- Remove
ɔ(latin small letter open o) symbol to prevent incorrect unicode parsing - Remove undocumented
scope.findwhich is a wrong abstraction for a new fork - Make
Scopea unit:- Add support for
Scopetois.unit - Add
is.scopemethod
- Add support for
- Allow to pass a scope to scopeBind:
scopeBind(unit, {scope}), which is also can be used outside from.watch - Improve es modules support
- Make package size 10% smaller
effector-react 22.0.0
- Add module
effector-react/scopeand makeeffector-react/ssran alias for it - Fix
Cannot update a component warninginuseGate - Allow to return undefined in
useStoreMap - Make
domainfield increateGateoptional - Deprecate
createContextComponentandcreateReactState - Improve es modules support
effector-vue 22.0.0
- Improve es modules support
forest 0.20.0
- Improve es modules support
- TypeScript
Published by zerobias over 4 years ago
effector - effector 21.8.12
- Fixed the conflict when used two versions of
effector/babel-pluginwithfactories - If incorrect values passed to
valuesorhandlersarguments toforkmethod, error will be thrown.
- TypeScript
Published by sergeysova over 4 years ago
effector - effector-react 21.3.1
- Fixed TypeError in
useStoreMapwith scope (PR #474)
- TypeScript
Published by sergeysova almost 5 years ago
effector - effector-react 21.3.0
- Add
useStoreMap($store, value => result)shorthand - Add support for
getKeytouseList. Function in this field will be used to compute key for every item of list - Add support for
updateFiltertouseStoreMap. It helps to control component rerendering, e.g. when component should rerender only whenidfield is changed - Add support for stores with functions in them to
useStore(PR #431) - Add domain name passed to
createGatetogate.displayNameand gate units (issue #449) - Fix unhandled promise rejection in
useEventwhen used effect throw an error
- TypeScript
Published by zerobias almost 5 years ago
effector - effector 21.8.0
js
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
```typescript
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
updateFilterconfig field tocreateStoreto skip arbitrary store updates (discussion #428)
js
const $playerPosition = createStore({x: 0, y: 0}, {
updateFilter: (update, current) => update.x !== current.x
})
- Add support for
samplewithclockwithoutsource. For example, it useful in cases whenclockis array of units and nosourcestores is needed
js
sample({
clock: [fx1.doneData, fx2.doneData],
fn: data => ({url: '/stats', data})
target: fetchFx,
})
- Add support for
clocktoguardto improve developer expirience in cases when update trigger (clockfield) and data source (sourcefield) are different things
js
guard({
clock: validateForm,
source: $formFields,
filter: formFields => validator(formFields),
target: submitFormFx,
})
Add
addNamesfield to babel plugin (PR #450)Add type support for
ScopetoclearNode(issue #441)Add
compositeNametoDomaintypings, making it consistent with other unitsAdd
EventPayloadandUnitValuetype helpers (PR #434)Improve various edge cases with fork api and serialization
Improve typechecking for
attach(issue #439)Fix various type issues in
sampleandguardtypings
- TypeScript
Published by zerobias about 5 years ago
effector - effector-react 21.2.0
- Add
createGateimplementation toeffector-react/ssr
```jsx import {createDomain} from 'effector' import {createGate, useGate} from 'effector-react/ssr'
const app = createDomain()
const currentRouteGate = createGate({ domain: app, defaultState: 'dashboard', })
export const Layout = ({routeName, children}) => { useGate(currentRouteGate, routeName) return ( <>
{routeName}
{children} </> ) } ```
- TypeScript
Published by zerobias about 5 years ago
effector - effector-react 21.1.0
- Add support for object and array of events to
useEvent. It's a shorthand for calling severaluseEventat once (PR #425 by @sergeysova)
```jsx export function ExampleComponent() { const handlers = useEvent({emailChanged, passwordChanged})
return (
```jsx export function ExampleComponent() { const [changeEmail, changePassword] = useEvent([ emailChanged, passwordChanged, ])
return (
- TypeScript
Published by zerobias over 5 years ago
effector - effector 21.7.0
Add support for scopes to
hydrate, to provide a way to fill additional values to existing scope (happens during SSG navigation in next.js)
- TypeScript
Published by zerobias over 5 years ago
effector - effector 21.6.0
- Add support for user-defined factories in fork api. Starting from this release, application developers can use their own functions and be sure that their content will be properly serialized and hydrated by fork api.
New field
factoriesineffector/babel-pluginaccepts array of module names which exports will be treated as custom factories therefore each function call will provide unique prefix forsidproperties of units inside them
json title=".babelrc"
{
"plugins": [
[
"effector/babel-plugin",
{
"factories": ["src/createEffectStatus", "~/createCommonPending"]
}
]
]
}
```js title="./src/createEffectStatus.js" import {rootDomain} from './rootDomain'
export function createEffectStatus(fx) { const $status = rootDomain .createStore('init') .on(fx.finally, (_, {status}) => status) return $status } ```
```js title="./src/statuses.js" import {createEffectStatus} from './createEffectStatus' import {fetchUserFx, fetchFriendsFx} from './api'
export const $fetchUserStatus = createEffectStatus(fetchUserFx) export const $fetchFriendsStatus = createEffectStatus(fetchFriendsFx) ```
Import createEffectStatus from './createEffectStatus' was treated as factory function so each store created by it has its own sid and will be handled by serialize independently, although without factories they will share the same sid
Add user-friendly unit name in fork api error messages when given unit is not found in scope. This improves error messages in both
effectorandeffector-reactAdd validation for
valuesandhandlersfields inforkand forvaluesfield inhydrateAdd type support for
createEffect<typeof handler, Error>(handler)to inferParamsandDonetypes from givenhandlerand provide customFailtype at the same time
createEffect and custom errors in documentation
Improve
guardreturn type inference (PR #406 (thanks @doasync))Fix void params support for
createEffect(name, config)(issue #404)Allow to use
Event<void>in cases when only() => voidis accepted (PR #400 (thanks @doasync))Add support for
mergetoeffector/babel-plugin
- TypeScript
Published by zerobias over 5 years ago
effector - effector 21.5.0
Add support for
attach({effect})to create effect which will calleffectwith params as it is. That allow to create separate effects with shared behavior (PR #396 and #397 (thanks @sergeysova and @oas89))Add
reactSsroption toeffector/babel-pluginto replace imports fromeffector-reacttoeffector-react/ssr. Useful for building both server-side and client-side builds from the same codebase
- TypeScript
Published by zerobias over 5 years ago
effector - effector 21.4.0
- Add support for return status to
allSettled. WhenallSettledis called withEffect, it return object withvalueandstatusfields (discussion)
js
import {createDomain, fork, allSettled} from 'effector'
const app = createDomain()
const fx = app.createEffect(() => 'ok')
const result = await allSettled(fx, {scope: fork(app)})
// => {status: 'done', value: 'ok'}
- Allow to expicitly define return/error types in
createEffect(handler)
typescript
const fx = createEffect<number, string, Error>(x => x.toString())
// fx has type Effect<number, string, Error>
Add types for
domain.effect(handler)Fix effector/babel-plugin behavior in case when methods like
createStoreare imported from unrelated library and should be ignored. Import library could be defined by importName config fieldImprove fork api support for watchers
- TypeScript
Published by zerobias over 5 years ago
effector - effector 21.3.0
- Add support for
createEffect(handler)
createEffect(handler) in documentation
```js import {createEffect} from 'effector'
const fetchUserReposFx = createEffect(async ({name}) => {
const url = https://api.github.com/users/${name}/repos
const req = await fetch(url)
return req.json()
})
fetchUserReposFx.done.watch(({params, result}) => { console.log(result) })
await fetchUserReposFx({name: 'zerobias'}) ```
- Add support for
attach({source, effect})withoutmapParams: in case withsourceandeffectonly, inner effect will be triggered withsourcevalues
attach({effect, source}) in documentation
js
import {createStore, createEffect, attach} from 'effector'
const request = createEffect()
const token = createStore('')
const secureRequest = attach({effect: request, source: token})
it's a shorthand for common use case:
js
import {createStore, createEffect, attach} from 'effector'
const request = createEffect()
const token = createStore('')
const secureRequest = attach({
effect: request,
source: token,
mapParams: (_, source) => source,
})
- Handle throws in
attachmapParamsfield: errors happened inmapParamsfunction will force attached effect to fail - Add babel plugin support for
splitandcreateApi - Add
namefield toattachtypings - Add
.filterand.filterMapto effect typings (PR #376) - Improve config validation for
forward,attach,sampleandguard: attempt to call these methods without arguments will lead to error with user-friendly description - Improve fork api support for stores and events
- TypeScript
Published by zerobias over 5 years ago
effector - effector 21.2.0
- Add array support for sample
clockfield which acts like amergecall
```typescript import {createStore, createEvent, createEffect, sample, merge} from 'effector'
const showNotification = createEvent
// array of units in clock sample({ source: store, clock: [trigger, fx.doneData], target: showNotification, })
// merged unit in clock sample({ source: store, clock: merge([trigger, fx.doneData]), target: showNotification, }) ```
- Improve ide type hints support for
samplein case of config form - Add
package.jsonto packageexportsfield (read more in nodejs documentation)
- TypeScript
Published by zerobias over 5 years ago
effector - effector 21.1.0
Add
onlyChangesoption toserializeto ignore stores which didn't changed in fork (prevent default values from being carried over network)Add type helpers for stores and effects:
StoreValue,EffectParams,EffectResultandEffectError
```typescript import { createStore, createEffect, StoreValue, EffectParams, EffectResult, } from 'effector'
const username = createStore('guest')
const getUserFX = createEffect
// string
type Username = StoreValue
// number
type GetUserParams = EffectParams
// {name: string}
type User = EffectResult
- Allow
domain.createEffectto infer type from givenhandler(that feature was already implemented forcreateEffectmethod), this code now typechecked as expected:
```typescript import {createDomain} from 'effector'
const app = createDomain()
const voidFx = app.createEffect({ async handler() {}, })
await voidFx() ```
- Allow to call
allSettledwith void units withoutparamsfield, this code now typechecked as expected:
```typescript import {createDomain, fork, allSettled} from 'effector'
const app = createDomain()
const voidFx = app.createEffect({ async handler() {}, })
voidFx()
const scope = fork(app)
await allSettled(voidFx, {scope}) ```
- TypeScript
Published by zerobias over 5 years ago
effector - effector 21.0.3, effector-react 21.0.4, effector-vue 21.0.3
- Improve native es modules support, add conditional exports declarations
- TypeScript
Published by zerobias over 5 years ago
effector - effector 21.0.0
- Add object form of
splitfor pattern-matching without additional forwards
```js import {split, createEffect, createEvent} from 'effector' const messageReceived = createEvent() const showTextPopup = createEvent() const playAudio = createEvent() const reportUnknownMessageType = 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, __: reportUnknownMessageType, }, })
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:
```js import {split, createStore, createEvent, createApi} from 'effector'
const textContent = createStore([])
const messageReceived = createEvent()
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'] ```
- Merge
effector/forkintoeffector. Now all methods required for SSR are exported from the library itself, makingeffector/forkan alias - Make
Scopetype alias forFork - Add support for es modules:
import {createStore} from 'effector/effector.mjs' - Effect without a handler now throws an error during a call instead of calling
console.errorwith undefined return, which was violating the type of effect - Remove
restorealiases,event.filter(fn)alias forevent.filterMap(fn),greedyinsampleas separate last argument and unusedblocksandKind
- TypeScript
Published by zerobias over 5 years ago
effector - effector-react 21.0.0
- Add support for es modules
- Remove experimental
Gate.isOpenplain property, which was incompatibile with concurrent mode and ssr, useGate.statusinstead
- TypeScript
Published by zerobias over 5 years ago
effector - effector-vue 21.0.0
- Add support for es modules
- TypeScript
Published by zerobias over 5 years ago
effector - effector-react 20.9.0
- Export
useGatewithforksupport fromeffector-react/ssr
```tsx import {useGate, useStore, Provider} from 'effector-react/ssr' import {createGate} from 'effector-react' import {createDomain, forward} from 'effector' import {fork} from 'effector/fork'
const app = createDomain()
const activeChatGate = createGate({domain: app})
const getMessagesFx = app.createEffect({ async handler({chatId}) { return ['hi bob!', 'Hello, Alice'] }, }) const messagesAmount = app .createStore(0) .on(getMessagesFx.doneData, (_, messages) => messages.length)
forward({ from: activeChatGate.open, to: getMessagesFx, })
const ChatPage = ({chatId}) => { useGate(activeChatGate, {chatId}) return (
Messages total: {useStore(messagesAmount)}
const scope = fork(app)
ReactDOM.render(
- Add
domainoptional field tocreateGatewhich will be used to create gate units (useful for ssr)
createGate({domain}) in documentation
- Improve
useListhook typings for typescript exported fromeffector-react/ssrby allowing usage as components' return value (fix DefinitelyTyped issue)
- TypeScript
Published by zerobias over 5 years ago
effector - effector 20.17.2
- Add effects created via
attachto domain effects, allowing these effects to be called within other effects when usingfork
```js import {createDomain, attach} from 'effector' import {fork, allSettled} from 'effector/fork'
const app = createDomain()
const add = app.createEffect({handler: _ => _})
const count = app.createStore(2).on(add.doneData, (x, y) => x + y)
const addWithCurrent = attach({ source: count, effect: add, mapParams: (params, current) => params + current, })
const start = app.createEffect({ async handler(val) { await addWithCurrent(val) }, })
const scope = fork(app)
await allSettled(start, { scope, params: 3, })
console.log(scope.getState(count)) // => 7 ```
- Add validation for
combinefirst argument which should be store, object with stores or array with stores PR #362 (thanks @doasync)
- TypeScript
Published by zerobias over 5 years ago
effector - effector 20.17.1
- Add validation for
event.watchwatcher, this code now throw error as expected:
```js import {createEvent} from 'effector'
const trigger = createEvent()
trigger.watch(NaN) // => Error: .watch argument should be a function ```
- TypeScript
Published by zerobias over 5 years ago
effector - effector 20.17.0
- Add support for nested effect calls in forked scope. Parallel requests are supported as well
```js import {createDomain, forward} from 'effector' import {fork, allSettled} from 'effector/fork'
const app = createDomain()
const addWord = app.createEffect({handler: async word => word}) const words = app .createStore([]) .on(addWord.doneData, (list, word) => [...list, word])
const start = app.createEffect({
async handler(word) {
await addWord(${word}1)
await addWord(${word}2)
return word
},
})
const next = app.createEffect({
async handler(word) {
await Promise.all([addWord(${word}3), addWord(${word}4)])
},
})
forward({from: start.doneData, to: next})
const scopeA = fork(app) const scopeB = fork(app) const scopeC = fork(app)
await Promise.all([ allSettled(start, { scope: scopeA, params: 'A', }), allSettled(start, { scope: scopeB, params: 'B', }), ])
await allSettled(start, { scope: scopeC, params: 'C', })
console.log(scopeA.getState(words)) // => [A1, A2, A3, A4] console.log(scopeB.getState(words)) // => [B1, B2, B3, B4] console.log(scopeC.getState(words)) // => [C1, C2, C3, C4] ```
- Allow
createNodeto call without arguments
```js import {createNode} from 'effector'
const node = createNode() ```
- Make
Steptype alias forNode
- TypeScript
Published by zerobias over 5 years ago
effector - effector-react 20.8.0
- Add ability to define default
Gatestate increateGateviadefaultStatefield
createGate({defaultState}) in documentation
- Remove
objectrestriction fromcreateGatePropstype in typescript, as it becomes useless with introduction ofuseGate. This code now passes type checking successfully
```typescript import {createGate} from 'effector-react'
const RouteGate = createGate
const UserGate = createGate({defaultState: 'guest'}) ```
- TypeScript
Published by zerobias over 5 years ago
effector - effector 20.16.1
- Allow typescript to refine type if
guardgotBoolean(a function) asfilter
```typescript import {createEvent, createStore, guard} from 'effector'
type User = {name: string}
const trigger = createEvent
guard({ source: trigger, filter: Boolean, target: user, }) ```
- TypeScript
Published by zerobias over 5 years ago
effector - effector-react 20.7.4
- Improve useStore support for React.StrictMode
- TypeScript
Published by zerobias over 5 years ago
effector - effector-vue 20.5.0
- Migrated from
Vue.util.defineReactivetoVue.observable - Effector stores will show in Vue devtools
- Cosmetic improvements for support plugin in the future
- Now we can add some units to effector object (will be return Store)
js const fx = createEffect({...}); export default Vue.extend({ effector: { isCompleted: fx.done }, watch: { isCompleted(sid) { this.isPopupOpened = false; } }, data: () => ({ isPopupOpened: true, }) }) - Support v-model directive for scalar values
js const $msg = createStore(); export default Vue.extend({ effector: { $msg }, })html <template> <input v-model="$msg"> </template>
- TypeScript
Published by zerobias over 5 years ago
effector - effector 20.16.0
- Add support for
handlerstoforkto change effect handlers for forked scope (useful for testing)
```typescript import {createDomain} from 'effector' import {fork, allSettled} from 'effector/fork'
//app const app = createDomain() const fetchFriends = app.createEffect<{limit: number}, string[]>({ async handler({limit}) { /* some client-side data fetching */ return [] }, }) const user = app.createStore('guest') const friends = app .createStore([]) .on(fetchFriends.doneData, (_, result) => result)
/* test to ensure that friends value is populated after fetchFriends call */ const testScope = fork(app, { values: { [user.sid]: 'alice', }, handlers: { [fetchFriends.sid]: () => ['bob', 'carol'], }, })
/* trigger computations in scope and await all called effects */ await allSettled(fetchFriends, { scope: testScope, params: {limit: 10}, })
/* check value of store in scope */ console.log(testScope.getState(friends)) // => ['bob', 'carol'] ```
- Add support for
scope.getState(store)to access to store values in forked scopes - Fix
valuessupport forfork
- TypeScript
Published by zerobias over 5 years ago
effector - effector-react 20.7.3, effector-vue 20.4.2
- Fix regression in
effector-react/compatandeffector-vue/compatcompatibility with IE11
- TypeScript
Published by zerobias over 5 years ago
effector - effector-vue 20.4.1
- Improve typescript typings for usage via
Vue.extend(PR #343)
- TypeScript
Published by zerobias almost 6 years ago
effector - effector 20.15.1
- Fix additional store updates during state hydration
```js import {createDomain, forward} from 'effector' import {hydrate} from 'effector/fork'
const app = createDomain()
const username = app.createStore('guest') const saveUser = app.createEffect({ handler(value) { console.log('saveUser now called only after store update', value) }, })
forward({ from: username, to: saveUser, })
username.updates.watch(value => { console.log('event watches now called only after store update', value) })
hydrate(app, { values: { [username.sid]: 'alice', }, }) // no event watches triggered yet and no effects called as we just hydrating app state ```
- TypeScript
Published by zerobias almost 6 years ago
effector - effector 20.15.0
- Add support for array of units to
store.on(PR #328)
```js import {createEvent, createStore} from 'effector'
const store = createStore(0) const changedA = createEvent() const changedB = createEvent()
store.on([changedA, changedB], (state, params) => state + params)
store.watch(value => { console.log('updated', value) })
changedA(2) // => updated 2
changedB(2) // => updated 4
// You can unsubscribe from any trigger store.off(changedA) ```
```js import {createEvent, createStore} from 'effector'
const store = createStore(0) const increment = createEvent() const reset = createEvent()
store.on(increment, state => state + 1).reset([reset])
store.watch(state => console.log('changed', state)) // changed 0 // watch method calls its function immediately
increment() // changed 1 increment() // changed 2 reset() // changed 0 ```
- Remove units erased with
clearNode(unit)from their parent domain hooks and history sets
- TypeScript
Published by zerobias almost 6 years ago