jeudi 28 juillet 2022

Emberjs inside of get computed making request to backend multiple times cause infinite loop

I have a table basically in every row i have get function that makes a backend request with store service. But somehow when there is one row it works expect, but when there is multiple rows it always try to recalculate get function which makes sending infinite request to backend. I am using glimmer component

I cannot use model relation on ember side at this point, there is deep chain on backend side. Thats why i am making backend request.

get <function_name>() {
  return this.store.query('<desired_model_name>', { <dependent1_id>: <dependent1_id_from_args>, <dependent2_id>: <dependent2_id_from_args> });
}

I fixed this problem with using constructor. But do you have any idea why this get function re-calculate all the time? Dependent_ids are constant.

Weird thing is when results are [] empty array it does not re calculate every time. Even the query results are same it still try to recalculate every time and making infinite request to backend.




Aucun commentaire:

Enregistrer un commentaire