Giter VIP home page Giter VIP logo

data_binding_proxy's Introduction

data binding with proxy

  • 使用Proxy來監聽Model的變動,並且更新畫面

Store

/src/model/index.js

import CommonModel from './CommonModel';

const counterModel = {
  count: 0
};

export default CommonModel({
  counter: counterModel,
});

Component

  • 如果需要用到store的話,就在class上方加入@Updator({store names}
  • this._model及為Updator載入的stores
  • render 用來產生初始化畫面
  • update 每當store變動時更新此component的畫面
import Updator from '../model/Updator';

@Updator('counter')
export default class Component {
  constructor(model) {
    this._model = model;

    ...
  }

  // re-render html
  update() {
    ...
  }

  // initial html
  render() {
    ...
  }
}

Updator

  • 使用Proxy偵測store是否有變動,有變動的話就觸發Component的update method更新畫面

data_binding_proxy's People

Contributors

bbandydd 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.