我已经由我自己编写了此功能
async function asyncAreaLoad() {
console.log( "asyncAreaLoad\t" + config.area + "\t" + room.id );
let check = await state.PersistanceManager.checkArea( config.area )
if ( check ) {
Logger.verbose( `PERSISTANCE:\troom: \t${room.id} EXIST, no Fetch` );
console.log( "NO FETCH" );
return;
}
const perLoader = state.EntityLoaderRegistry.get( 'persistence' );
perLoader.setArea( config.area );
const haveItems = await perLoader.hasData();
if ( !haveItems ) {
Logger.verbose( `PERSISTANCE:\t\tArea\t[${config.area}]\t with NO DATA!` );
console.log( "NO DATA" );
return;
}
let aw = await perLoader.fetchAll();
console.log( "FETCHED" );
state.PersistanceManager.addArea( config.area, aw.rooms );
Logger.verbose( `PERSISTANCE:\t\tArea\t[${config.area}]\t LOADED!` );
console.log( "Loaded" );
// state.PersistanceManager.populateArea( config.area );
}
await asyncAreaLoad();
如何从结果中看到该函数已被触发四次,并且该区域的名称是相同的 valinorCastle 。 我期望 perLoader.fetchAll 被触发一次,因为 addArea 使 checkArea < / em> 返回 true 。 相反,我得到了这个
结果:
asyncAreaLoad valinorCastle valinorCastleMainRoom
asyncAreaLoad valinorCastle valinorCastle2
asyncAreaLoad valinorCastle valinorCastle3
asyncAreaLoad valinorCastle valinorCastle4
**FETCHED**
**AddedArea valinorCastle**
Loaded
**FETCHED**
Loaded
**FETCHED**
Loaded
**FETCHED**
Loaded