@act/optimistic 中文文档教程

发布于 8年前 浏览 17 项目主页 更新于 3年前

Act
一个简单的响应式前端框架

 


Act optimistic updates

Act 乐观更新 hello world:

import main from '@act/optimistic'
import map from 'ramda/src/map'
import valueOnEnter from '@act/main/processes/valueOnEnter'

const add = (payload, history) =>
  history.push({ type: 'success', payload }, (rollback) =>
    setTimeout(rollback, 5000))

const view = (comments) =>
  ['main', [
    ['input', { keyup: [add, valueOnEnter], value: '' }],
    ...map((comment) => ['div', comment], comments)
  ]]

const reducer = (state = [], { type, payload }) =>
  type === 'success' ? [...state, payload] : state

main(view, { reducer })

More

此模块的文档是 Act 的的一部分 文档。

Act
A simple reactive front-end framework

 


Act optimistic updates

Act optimistic updates hello world:

import main from '@act/optimistic'
import map from 'ramda/src/map'
import valueOnEnter from '@act/main/processes/valueOnEnter'

const add = (payload, history) =>
  history.push({ type: 'success', payload }, (rollback) =>
    setTimeout(rollback, 5000))

const view = (comments) =>
  ['main', [
    ['input', { keyup: [add, valueOnEnter], value: '' }],
    ...map((comment) => ['div', comment], comments)
  ]]

const reducer = (state = [], { type, payload }) =>
  type === 'success' ? [...state, payload] : state

main(view, { reducer })

More

The documentation for this module is part of Act's docs.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文