本文整理匯總了TypeScript中rsvp.hash函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript hash函數的具體用法?TypeScript hash怎麽用?TypeScript hash使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了hash函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: hash
.then((result) => {
return hash({
limitedArticleEntries: result.allArticleEntries.slice(0, 2),
limitedJournalEntries: result.allJournalEntries.slice(0, 2),
limitedBitEntries: result.allBitEntries.slice(0, 2)
})
})
示例2: model
model () {
let shoebox = this.fastboot.shoebox
let shoeboxStore = shoebox.retrieve('now')
let text = this.markdownResolver.file('text', 'now')
let currentlyListening
if (this.fastboot.isFastBoot) {
currentlyListening = this.apollo
.query({ query })
.then((result) => {
if (!shoeboxStore) {
shoeboxStore = {}
shoebox.put('now', shoeboxStore)
}
shoeboxStore.currentlyListening = result.currentlyListening
return result.currentlyListening
})
.catch(console.error)
} else {
currentlyListening = shoeboxStore ? shoeboxStore.currentlyListening : null
if (!currentlyListening) {
currentlyListening = this.apollo
.query({ query })
.then((result) => result.currentlyListening)
}
}
return hash({
text,
currentlyListening
})
}
示例3: model
model(params, transition) {
const store = this.get('store');
const id = params.housingRequestId;
const housingRequest = store.findRecord('housing-request', id, {
include: 'registration,housing_provision'
});
return RSVP.hash({ housingRequest });
}
示例4: testHash
function testHash() {
let promises = {
myPromise: RSVP.resolve(1),
yourPromise: RSVP.resolve('2'),
theirPromise: RSVP.resolve({ key: 3 }),
notAPromise: 4,
};
RSVP.hash(promises, 'my label').then(function(hash) {
assertType<number>(hash.myPromise);
assertType<string>(hash.yourPromise);
assertType<{ key: number }>(hash.theirPromise);
assertType<number>(hash.notAPromise);
});
}
示例5: model
model () {
return hash({
text: this.markdownResolver.file('text', 'bookshelf')
})
}
示例6: return
let filterFn = (item: number) => {
return item > 1;
};
RSVP.filter(promiseArray, filterFn).then(result => {});
RSVP.hashSettled(promiseHash).then(hash => {
return (
hash.promiseA.state === 'fulfilled' &&
hash.promiseB.value === 2 &&
hash.promiseC.reason === '3' &&
hash.notAPromise.state === 'fulfilled'
);
});
RSVP.hash(promiseHash).then(
values => {
return (
values.promiseA < 0 &&
values.promiseB === 4 &&
values.promiseC === 12 &&
values.notAPromise > 0
);
},
err => {}
);
let mapFn = function(item: number) {
return item + 1;
};
RSVP.map(promiseArray, mapFn).then(function(result) {});
示例7: model
model () {
return hash({
bio: this.markdownResolver.file('text', 'about/bio'),
blurb: this.markdownResolver.file('text', 'about/blurb')
})
}