本文整理汇总了TypeScript中flash-store.FlashStoreSync.ready方法的典型用法代码示例。如果您正苦于以下问题:TypeScript FlashStoreSync.ready方法的具体用法?TypeScript FlashStoreSync.ready怎么用?TypeScript FlashStoreSync.ready使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flash-store.FlashStoreSync
的用法示例。
在下文中一共展示了FlashStoreSync.ready方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: initCache
protected async initCache(
token : string,
userId : string,
): Promise<void> {
log.verbose('PuppetPadchatManager', 'initCache(%s, %s)', token, userId)
if ( this.cacheContactRawPayload
|| this.cacheRoomMemberRawPayload
|| this.cacheRoomRawPayload
) {
throw new Error('cache exists')
}
const baseDir = path.join(
os.homedir(),
path.sep,
'.wechaty',
'puppet-padchat-cache',
path.sep,
token,
path.sep,
userId,
)
const baseDirExist = await fs.pathExists(baseDir)
if (!baseDirExist) {
await fs.mkdirp(baseDir)
}
this.cacheContactRawPayload = new FlashStoreSync(path.join(baseDir, 'contact-raw-payload'))
this.cacheRoomMemberRawPayload = new FlashStoreSync(path.join(baseDir, 'room-member-raw-payload'))
this.cacheRoomRawPayload = new FlashStoreSync(path.join(baseDir, 'room-raw-payload'))
await Promise.all([
this.cacheContactRawPayload.ready(),
this.cacheRoomMemberRawPayload.ready(),
this.cacheRoomRawPayload.ready(),
])
const roomMemberTotalNum = [...this.cacheRoomMemberRawPayload.values()].reduce(
(accuVal, currVal) => {
return accuVal + Object.keys(currVal).length
},
0,
)
log.verbose('PuppetPadchatManager', 'initCache() inited %d Contacts, %d RoomMembers, %d Rooms, cachedir="%s"',
this.cacheContactRawPayload.size,
roomMemberTotalNum,
this.cacheRoomRawPayload.size,
baseDir,
)
}