Skip to content

effector 21.3.0

Choose a tag to compare

@zerobias zerobias released this 07 Sep 16:31
· 3250 commits to master since this release
6f46c57
  • Add support for createEffect(handler)

createEffect(handler) in documentation

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'})

Try it

  • Add support for attach({source, effect}) without mapParams: in case with source and effect only, inner effect will be triggered with source values

attach({effect, source}) in documentation

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:

import {createStore, createEffect, attach} from 'effector'
const request = createEffect()
const token = createStore('')
const secureRequest = attach({
  effect: request,
  source: token,
  mapParams: (_, source) => source,
})

Try it

  • Handle throws in attach mapParams field: errors happened in mapParams function will force attached effect to fail
  • Add babel plugin support for split and createApi
  • Add name field to attach typings
  • Add .filter and .filterMap to effect typings (PR #376)
  • Improve config validation for forward, attach, sample and guard: attempt to call these methods without arguments will lead to error with user-friendly description
  • Improve fork api support for stores and events