You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
method to capture the data from wire @wire(getRecord, {...props}) setSomeRecord(recordData) { this.storeWired('some record', recordData); }
method to get the data from storage this.getWired('some record') => Promise
Solution draft
classA{someProp;
@wire(getSomeProp)setSomeProp({data, error}){// proto for "setSomeRecord"if(data){this.someProp=data;this.somePropAwaitList.forEach(([resolve])=>resolve(this.someProp));}if(error){this.somePropAwaitList.forEach(([resolve,reject])=>reject(error));console.error(error);}}somePropAwaitList=[];awaitSomeProp=()=>{// proto for "getWired"if(this.someProp!==undefined){returnPromise.resolve(this.someProp);}else{returnnewPromise((resolve,reject)=>{this.somePropAwaitList=[...this.somePropAwaitList,[resolve,reject]];});}}}
The text was updated successfully, but these errors were encountered:
Actually, you can return the same promise to each requestor. Proof:
letresolve;letreject;constresolved=newPromise((r,j)=>{resolve=r;reject=j;});setTimeout(()=>{console.log("now let's resolve");resolve();},3000);setTimeout(()=>{console.log("add first listener");resolved.then(()=>console.log('1'));},1000);setTimeout(()=>{console.log("add second listener");resolved.then(()=>console.log('2'));},2000);setTimeout(()=>{console.log("add third listener");resolved.then(()=>console.log('3'));},4000);
Result
add first listener
add second listener
now let's resolve
1
2
add third listener
3
API
WireHelperMixin
(naming TBD)@wire(getRecord, {...props}) setSomeRecord(recordData) { this.storeWired('some record', recordData); }
this.getWired('some record') => Promise
Solution draft
The text was updated successfully, but these errors were encountered: