Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

封装异步渲染的组件 #8

Closed
axetroy opened this issue May 4, 2017 · 0 comments
Closed

封装异步渲染的组件 #8

axetroy opened this issue May 4, 2017 · 0 comments

Comments

@axetroy
Copy link
Owner

axetroy commented May 4, 2017

有点类似Angular的Async管道

<span>Wait for it... {{ greeting | async }}</span>

之前有写过类似的库

ng-promise, 根据promise的结果渲染不同的视图

现在要实现React版

初步拟定组件是这么用的

import { Async, Resolve, Reject, Finally } from '@axetroy/react-async';

class App extends Component {
  render() {
    return (
      <Async wait={Promise.resolve(data)}>
        <Resolve>promise resolve</Resolve>
        <Reject>promise reject</Reject>
        <Finally>promise done, whatever it is reject or resolve</Finally>
      </Async>
    );
  }
}

已完成

react-async

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant