Flux 模式实现 DeLorean

码农软件 · 软件分类 · Node.js 扩展 · 2019-04-15 09:59:44

软件介绍

DeLoreanjs(Delorean.js) 是极小的 Flux 模式实现:

  • 单向数据流,是的你的应用逻辑比 MVC 还简单

  • 自动监听数据变化情况,保持数据持续更新


  • 这是个很完整的框架,没有视图框架

  • 非常小,压缩后只有 4K

  • 内置 React.js 集成,易于使用 Flight.jsReactive.js 或者其他的 JS 库

  • 使用回滚提高 UI 和数据的一致性

示例:

/* * Stores are simple data buckets which manages data. */var Store = Flux.createStore({
  data: null,
  setData: function (data) {
    this.data = data;
    this.emit('change');
  },
  actions: {
    'incoming-data': 'setData'
  }});var store = new Store();/* * Dispatchers are simple action dispatchers for stores. * Stores handle the related action. */var Dispatcher = Flux.createDispatcher({
  setData: function (data) {
    this.dispatch('incoming-data', data);
  },
  getStores: function () {
    return {increment: store};
  }});/* * Action Creators are simple controllers. They are simple functions. *  They talk to dispatchers. They are not required. */var Actions = {
  setData: function (data) {
    Dispatcher.setData(data);
  }};// The data cycle.store.onChange(function () {
  // End of data cycle.
  document.getElementById('result').innerText = store.store.data;});document.getElementById('dataChanger').onclick = function () {
  // Start data cycle:
  Actions.setData(Math.random());};


本文地址:https://www.codercto.com/soft/d/3620.html

Head First HTML5 Programming

Head First HTML5 Programming

Eric Freeman、Elisabeth Robson / O'Reilly Media / 2011-10-18 / USD 49.99

What can HTML5 do for you? If you're a web developer looking to use this new version of HTML, you might be wondering how much has really changed. Head First HTML5 Programming introduces the key featur......一起来看看 《Head First HTML5 Programming》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换