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
Currently when an inject fails to resolve, nothing happens, and the injected value just remains untouched. This seems like an opportunity to warn the developer that an inject could not be resolved.
Perhaps this is intended behavior. Maybe it makes sense that sometimes an injection would not be resolved. If that is the case, could there be a way to indicate a given inject is required? A stricter injection method?
My current workaround is to throw an error if the object is undefined as of create (since injects are resolved by then), but it's a manual step that must be made in many places.
What does the proposed API look like?
If a new API is needed to support this, I am not sure how to design it.
As for warning, I was hoping that when an inject could not be resolved, there would be a warning in the browser console.
The text was updated successfully, but these errors were encountered:
@Lokson This is any situation in which a child component has an inject which can't be satisfied by a provide in itself or any of its component ancestors, including the root Vue object itself.
I ran into this while developing a validation service. Basically, I have a ValidationService class which is a provide on a top level component which represents a collection of form inputs. The inputs themselves are very complicated, so they are their own Vue components:
If, when building this, I forget to provide the ValidationService on the parent FormComponent, the ComplicatedInput components will silently never have their reference to ValidationService injected. This results in errors related to accessing members of an undefined object, etc.
My theory here and the reason for this feature request is that getting some kind of indication that an inject went unsatisfied seems useful for development.
What problem does this feature solve?
Currently when an
inject
fails to resolve, nothing happens, and the injected value just remains untouched. This seems like an opportunity to warn the developer that aninject
could not be resolved.Perhaps this is intended behavior. Maybe it makes sense that sometimes an injection would not be resolved. If that is the case, could there be a way to indicate a given inject is required? A stricter injection method?
My current workaround is to throw an error if the object is undefined as of
create
(since injects are resolved by then), but it's a manual step that must be made in many places.What does the proposed API look like?
If a new API is needed to support this, I am not sure how to design it.
As for warning, I was hoping that when an
inject
could not be resolved, there would be a warning in the browser console.The text was updated successfully, but these errors were encountered: