How to use the effector/fork.allSettled function in effector

To help you get started, we’ve selected a few effector examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zerobias / effector / examples / react-ssr / src / server.tsx View on Github external
server.get(`/${key}`, async(req, res) => {
    try {
      const scope = fork(app)
      await allSettled(startServer, {
        scope,
        params: users[key],
      })
      const data = serialize(scope)
      const content = renderToString()
      const result = await compile({content, data})
      res.send(result)
    } catch (err) {
      console.error(err)
      res.status(500).send('something going wrong')
    }
  })
}
github zerobias / effector / examples / react-ssr / src / client.tsx View on Github external
import {fork, allSettled} from 'effector/fork'
import {App, app, location$, startClient} from './app'

const history = createBrowserHistory()

location$.updates.watch(location => {
  if (history.location !== location) {
    history.push(location)
  }
})

const clientScope = fork(app, {
  values: window.__initialState__,
})

allSettled(startClient, {
  scope: clientScope,
  params: history,
}).then(() => {
  ReactDOM.hydrate(, document.getElementById('root'))
})
github zerobias / effector / examples / serverless-ssr / src / client.tsx View on Github external
import {fork, allSettled} from 'effector/fork'
import {App, location$, startClient} from './app'
import {app} from './domain'

const history = createBrowserHistory()

location$.updates.watch(location => {
  if (history.location !== location) {
    history.push(location)
  }
})

const scope = fork(app, {
  values: (window as any).__initialState__,
})
allSettled(startClient, {
  scope,
  params: history,
})
ReactDOM.hydrate(, document.getElementById('root'))