基于ember.js的preload_store
来源:互联网 发布:ubuntu 14.10 下载 编辑:程序博客网 时间:2024/06/14 05:22
define("preload-store",
["exports"],
function(__exports__) {
"use strict";
/**
We can insert data into the PreloadStore when the document is loaded.
The data can be accessed once by a key, after which it is removed
@class PreloadStore
**/
__exports__["default"] = {
data: {},
store: function (key, value) {
this.data[key] = value;
},
/**
To retrieve a key, you provide the key you want, plus a finder to load
it if the key cannot be found. Once the key is used once, it is removed
from the store.
So, for example, you can't load a preloaded topic more than once.
**/
getAndRemove: function (key, finder) {
if (this.data[key]) {
var promise = Em.RSVP.resolve(this.data[key]);
delete this.data[key];
return promise;
}
if (finder) {
return new Ember.RSVP.Promise(function (resolve, reject) {
var result = finder();
// If the finder returns a promise, we support that too
if (result && result.then) {
result.then(function (toResolve) {
return resolve(toResolve);
}).catch(function (toReject) {
return reject(toReject);
});
} else {
resolve(result);
}
});
}
return Ember.RSVP.resolve(null);
},
get: function (key) {
return this.data[key];
},
remove: function (key) {
if (this.data[key]) delete this.data[key];
},
reset: function () {
this.data = {};
}
};
});
["exports"],
function(__exports__) {
"use strict";
/**
We can insert data into the PreloadStore when the document is loaded.
The data can be accessed once by a key, after which it is removed
@class PreloadStore
**/
__exports__["default"] = {
data: {},
store: function (key, value) {
this.data[key] = value;
},
/**
To retrieve a key, you provide the key you want, plus a finder to load
it if the key cannot be found. Once the key is used once, it is removed
from the store.
So, for example, you can't load a preloaded topic more than once.
**/
getAndRemove: function (key, finder) {
if (this.data[key]) {
var promise = Em.RSVP.resolve(this.data[key]);
delete this.data[key];
return promise;
}
if (finder) {
return new Ember.RSVP.Promise(function (resolve, reject) {
var result = finder();
// If the finder returns a promise, we support that too
if (result && result.then) {
result.then(function (toResolve) {
return resolve(toResolve);
}).catch(function (toReject) {
return reject(toReject);
});
} else {
resolve(result);
}
});
}
return Ember.RSVP.resolve(null);
},
get: function (key) {
return this.data[key];
},
remove: function (key) {
if (this.data[key]) delete this.data[key];
},
reset: function () {
this.data = {};
}
};
});
0 0
- 基于ember.js的preload_store
- Ember.js 的初学者指南
- Ember.js 的初学者指南
- Ember.js的那些坑
- Ember.js的那些坑
- ember.js
- 深入解读ember.js的对象体系
- ember.js提供的基础服务介绍
- ember.js的render过程分析
- 使用ember-simple-auth实现Ember.js应用的权限控制
- Ember.js常用函数
- ember.js教程
- Ember.js学习总结
- Ember.js实战
- Ember.js--入门
- Ember.js学习笔记
- Ember.js学习笔记
- 介绍javascript的ember.js框架的几篇文章
- GC回收机制
- mod
- [Leetcode,python] Hamming Distance 汉明距离
- Ubuntu16.04下 Matlab2015b安装与激活及注意事项:
- 剪贴板增强---Kawvin增强剪贴板_V2.0
- 基于ember.js的preload_store
- 一次初始化-pthread_once_t
- DOM节点的基本使用以及数据转成JSON
- Arpa's loud Owf and Mehrdad's evil plan 742C--环的处理
- Android View坐标系详解(getTop()、getX、getTranslationX...)
- datagrid中实现时间调节
- HDOJ 5996 dingyeye loves stone(阶梯博弈)
- 677/AVanya and Fence
- Redis 集群搭建