本文整理汇总了TypeScript中@ember-decorators/object.computed函数的典型用法代码示例。如果您正苦于以下问题:TypeScript computed函数的具体用法?TypeScript computed怎么用?TypeScript computed使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了computed函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: maxAvatarLength
/**
* Calculates the max number of avatars to render
* @type {ComputedProperty<number>}
* @memberof StackedAvatarsList
*/
@computed('avatars.length')
get maxAvatarLength(): number {
const {
avatars: { length }
} = this;
return length ? Math.min(length, defaultMavAvatarLength) : defaultMavAvatarLength;
}
示例2: showClearBtn
/**
* Computed property to check if there is any selection in the
* facet. If that is the case, a clear button will show up.
*/
@computed('selections')
get showClearBtn(): boolean {
const selections = this.selections || {};
return Object.keys(selections).reduce((willShowClearBtn: boolean, selectionKey: string) => {
return willShowClearBtn || selections[selectionKey];
}, false);
}
示例3: bootstrapVersion
/**
* Returns the bootstrap version defined in the config, depending on this value the colums will be rendered differently
*/
@computed('config')
get bootstrapVersion() : number | undefined {
const config = this.config;
if(config.hasOwnProperty('ember-mist-components') && config['ember-mist-components'].hasOwnProperty('bootstrapVersion')) {
return config['ember-mist-components'].bootstrapVersion;
}
return;
}
示例4: records
/**
* Returns the Recently Viewed records currently in local storage, if nothing is found an empty array is returned
*/
@computed('storage.recentlyViewedRecords.[]')
get records() : RecentlyViewedRecord[] {
let oldRecentlyViewedRecords : RecentlyViewedRecord[] = this.storage.get('recentlyViewedRecords');
if(isBlank(oldRecentlyViewedRecords)) {
oldRecentlyViewedRecords = [];
}
return oldRecentlyViewedRecords;
}
示例5: headers
/**
* We set the authorization header from the session service
*/
@computed('session.data.authenticated.access_token')
get headers() {
const headers: any = {};
const access_token = this.get('session.data.authenticated.access_token');
if(!isBlank(access_token)) {
headers['Authorization'] = `Bearer ${access_token}`;
}
return headers;
}
示例6: _styleString
@attribute('style')
@computed('style')
get _styleString() {
let s: JSONObject = this.get('style');
let sProps = [];
for (let i in s) {
if (s.hasOwnProperty(i)) {
sProps.push([i, s[i]]);
}
}
return sProps.map(x => `${x[0]}: ${x[1]}`).join('; ');
}
示例7: outputDisplayRows
@computed('displayRows')
get outputDisplayRows() : any[] {
let outputDisplayRows = [];
if(!isBlank(this.displayRows)) {
for(let row of this.displayRows) {
let emptyRow = true;
for(let column of row.columns) {
column.component = replaceAll(column.component, 'input', 'output');
if(emptyRow) {
emptyRow = isBlank(this.address.get(column.field));
}
}
row.emptyRow = emptyRow;
outputDisplayRows.push(row);
}
}
return outputDisplayRows;
}
示例8: _contentUrl
@computed('providerUrl', 'src')
get _contentUrl() {
let params: any = this.get('providerParams');
let queryParams = JSON.parse(JSON.stringify(params)) || {};
queryParams.url = this.get('src');
let queryParamList = [];
for (let k in queryParams) {
if (queryParams.hasOwnProperty(k)) {
queryParamList.push([k, queryParams[k]]);
}
}
let queryString =
queryParamList.length > 0
? queryParamList
.map(x => {
return `${x[0]}=${x[1]}`;
})
.join('&')
: '';
const url: string = this.get('providerUrl') || '';
return `${url}?${queryString}`;
}
示例9: items
@computed('value.@each')
get items() : MutableArray<string> {
return this.value ? this.value : A();
}
示例10: transform
/**
* transform SVG attribute for deacon SVG group - computed from x and y of supplied model
*/
@attribute @computed('model.x','model.y') get transform() : string {
return "translate(" + this.model.x + "," + this.model.y + ")";
}