GithubHelp home page GithubHelp logo

lqliqiong / plume2 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from qianmiopen/plume2

0.0 1.0 0.0 1.27 MB

🚀a lightweight React state container for web and app

Home Page: https://hufeng.github.io/plume2/

License: MIT License

JavaScript 3.55% TypeScript 96.45%

plume2's Introduction

New Idea, New the World. 🔥🔥🔥

技术也是时尚驱动的,我们常常臣服于时尚,面对快速的变化常常让我们局促不安, 开始焦虑,唯恐错过了些什么。怎么打破这种焦虑?需要在快速变化得世界里保持清醒, 保持独立的思考和认知。 让我们回归到技术的本质, 因为解决了真实的问题,技术才变得有价值。 真正牛*的技术,都是静悄悄的跑在线上...

plume2 🚀🚀🚀

light weight framework for mobile web

NPM

Reactive and Predictable state container for React or ReactNative.

  • Thanks Immutable.js
  • Thanks MapReduce
  • Thanks Functional Reactive Programming.

iflux

很早很早之前,我们爱上了React and immutable,所以就有了很简单的iflux。

iflux = immutable.js + react.js

NPM

保持简单

+-----------------------+
|       WebApi          |
+-----------------------+
          |  
         \|/
+-----------------------+
|   Store(immutable)   |<-----+
+-----------------------+      |
           | //es5 style       |
           | StoreMixin        | msg(EventEmitter)
          \|/                  |
+------------------------+     |
|     React App          |-----|
+------------------------+
|      <Layout>          |
|        <SearchForm/>   |
|        <Toolbar/>      |
|        <DataGrid/>     |
|       </Layout>        |
+------------------------+

优点:

  • 简单直接,几乎没有什么规则
  • 单根数据源(single data source)
  • Immutable fronted UI
  • High Performance

但是随着业务的不断的发展,数据层的复杂度也在上升。这时候iflux就会暴露出很多的缺点

  • Big Store, Store中大量的数据和业务的处理,代码膨胀的厉害
  • Store是单例,不销毁,有共享的问题
  • store的数据通过props不断的透传,代码写的很费劲
  • 大量的数据之间的依赖关系,需要手动的保证和处理

怎么解决?

  • 使用MapReduce的理念解决big Store
  • 使用@Relax自动注入store中的数据和事件
  • Store不再是单例
  • 使用FRP的理念, 简单的实现反应式数据,抽象源数据和派生数据

这就是我们的plume2

+------------------+
|     BFF-API      |
+------------------+
        ||
        \/
+------------------+
|     WebApi       |
+------------------+
        ||
        \/
+------------------+
|     Store        | ====> [Actor1, Actor2, Actor3]
+------------------+
        ||
        \/
+------------------+
|  @StoreProvider  |
+------------------+
        ||
        \/
+------------------+
|     @Relax       |
+------------------+
        ||
        \/
+------------------+
|     QL/DQL       |
+------------------+

Getting Started

# add dependencies
yarn add plume2 # npm install plume2

# web
yarn add react react-dom # yarn add preact preact-compat

quick demo

//四大领域对象
//Actor, Store, StoreProvider, Relax

class HelloActor extends Actor {
  defaultState() {
    return {text: 'hello world'}
  }
}

class AppStore extends Store {
  bindActor() {
    return [new HelloActor]
  }
}

@Relax
class Text extends React.Component {
  static relaxProps = {
    text: 'text'
  };

  render() {
    const {text} = this.props.relaxProps
    return <div>{text}</div>
  }
}


@StoreProvider(AppStore)
class HelloApp extends React.Component {
  render() {
    return <Text/>
  }
}

ReactDOM.render(<HelloApp/>, document.getElementById('app'))

contributes

thanks all(pr, issue)

plume2 git/master  
❯ git summary

 project  : plume2
 repo age : 8 months
 active   : 42 days
 commits  : 164
 files    : 191
 authors  : 
   149	hufeng  90.9%
    14	胡锋    8.5%
     1	blsery  0.6%

plume2's People

Contributors

hufeng avatar lisong2010 avatar

Watchers

 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.