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
Note that in this case every single time an injection runs, the injector will recompute (find) the FormBaseModel - which might be costly. In some cases this might be required, but I think that we should have a rule that if the injection callback returns a value, then that value that is returned is memoized (cached) for next time the injection is evaluated rather than calling the callback all over again.
Target Code:
export default class FormBaseController extends Controller {
constructor() {
super();
// Our callback will only be called once, and then after that it will reuse the returned value.
this.injections.formModel = () => this.modelWatcher.find(FormBaseModel);
}
}
However, if the injection property (formModel in this case) is ever overwritten with a new function or a new value, then the memoized value needs to be discarded so we will have to watch for changes to the injection value (in this case formModel)
The text was updated successfully, but these errors were encountered:
Example code:
Note that in this case every single time an injection runs, the injector will recompute (find) the FormBaseModel - which might be costly. In some cases this might be required, but I think that we should have a rule that if the injection callback returns a value, then that value that is returned is memoized (cached) for next time the injection is evaluated rather than calling the callback all over again.
Target Code:
However, if the injection property (
formModel
in this case) is ever overwritten with a new function or a new value, then the memoized value needs to be discarded so we will have to watch for changes to the injection value (in this caseformModel
)The text was updated successfully, but these errors were encountered: