나는 이온 2 프로젝트에 종사하고있다. 기기/휴대 전화의 모든 연락처를 반환 할 수 있습니다. 하지만 한 번에 하나의 요청으로 인해 성능이 매우 떨어지는 약속 코드를 사용했습니다. 자, 약속 된 코드를 관찰 대상으로 변경하고 싶습니다. 이 문제를 해결하도록 도와주세요. 약속을 관측 가능으로 변환하는 방법은 무엇입니까?
findContact(searchKey){
if(searchKey.target.value == "" || searchKey.target.value == undefined || searchKey.target.value == null){
this.contactSelected = false;
} else{
this.contactSelected = true;
}
let options = {
multiple: true,
hasPhoneNumber: true,
filter: searchKey.target.value
}
let cantactFields = ['displayName', 'phoneNumbers'];
Contacts.find(cantactFields, options).then(res => {
this.contactResults = res;
}, (er) => {
console.log(er);
})
}
Contacts.find()
당신은 가능성이 XY로 문제가 발생하는 데 도움이됩니다. 약속과 관찰 가능 모두 동시에 여러 요청을 처리 할 수 있습니다. 그리고 질문은 관련 코드를 표시하지 않습니다. – estus