设为首页收藏本站

LUPA开源社区

 找回密码
 注册
文章 帖子 博客
LUPA开源社区 首页 业界资讯 软件追踪 查看内容

DeLoreanJS 0.8.3发布,极小的Flux模式实现

2014-9-29 15:58| 发布者: joejoe0332| 查看: 1943| 评论: 0|原作者: oschina|来自: oschina

摘要:   DeLoreanJS 0.8.3 发布,此版本现已提供下载。  DeLoreanjs(Delorean.js) 是极小的Flux模式实现:单向数据流,是的你的应用逻辑比 MVC 还简单自动监听数据变化情况,保持数据持续更新这是个很完整的框架,没 ...

  DeLoreanJS 0.8.3 发布,此版本现已提供下载


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

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

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


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

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

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

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


  示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* * 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());};

酷毙

雷人

鲜花

鸡蛋

漂亮
  • 快毕业了,没工作经验,
    找份工作好难啊?
    赶紧去人才芯片公司磨练吧!!

最新评论

关于LUPA|人才芯片工程|人才招聘|LUPA认证|LUPA教育|LUPA开源社区 ( 浙B2-20090187 浙公网安备 33010602006705号   

返回顶部