Giter Site home page Giter Site logo

react-rxjs-demo's Introduction

一个将rxjsreact结合使用的演示库

本工程来源于一次内部分享,分享稿点这里

demo-image

  • 创建目的:尝试rxjs 6的操作符;锻炼函数式+响应式编程的思维方式;探索与react工程化结合方式
  • 已包括
    • pipe中使用多个操作符组合操作数据
    • 演示在异步操作(多个异步组合)中的应用
    • 演示动画&游戏制作思路
    • 演示组件通信
  • 已实现
    • 一种状态管理方式:高阶组件给调用者提供流式操作组件数据的方式
    • 父子组件&兄弟组件通信方式:在props中提供调用流的能力
  • 待实现
    • 完整的rxjs状态管理方案

数据流方案

rxjs是一个专注数据和事件流处理的库,这让他有能力去尝试替代react内常用的状态管理方案redux,但是单纯去替代redux似乎没有什么意义。是的,我们更在乎的是带给我们的能力。为此,我目前有如下的一个方案,这在我当前的demo中看起来运行还不错,因为会不停发展,因此暂时把它称为plan A(src/rx/hoc withStream)。

特性

  • 支持把普通属性映射到props。该属性可以在stream$中使用
  • 支持把普通方法映射到props。该方法内可以使用(state, stream$)state表示当前状态,stream$.next({propName: propValue})可以更新到下一个状态
  • 支持把流属性映射到props。该流会被其他流属性一起合并,最终提供一个外部流observable$,目前只开放它的解除订阅的方法const {unsubscribe} = this.props。所有流属性最终都会被映射为StreamComponent的普通属性(通过订阅实现)。

下一阶段

  • 支持多个外部流
  • 支持状态多播

license

MIT

react-rxjs-demo's People

Contributors

dependabot[bot] avatar wanderhuang avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.