Question about injection context
When I started, I had the impression that everything inside
If I understood correctly - the first time the callback is called (on "initialization") it IS in an injection context, but if one of the dependent signal changes and triggers a rerun of the method, this will not work anymore, causing exceptions. that are quite hard to debug, if you used
I wonder if it might be a better implementation to
It's very likely that almost any query will have DI dependencies (like HTTTP) and I believe the current implementation might make the DX a bit difficult.
injectQuery (the main callback for the function, and any other functions like queryFn) is guaranteed to be called in injection context, but I now noticed that this might not be the case. If I understood correctly - the first time the callback is called (on "initialization") it IS in an injection context, but if one of the dependent signal changes and triggers a rerun of the method, this will not work anymore, causing exceptions. that are quite hard to debug, if you used
inject somewhere inside it.I wonder if it might be a better implementation to
inject(Injector) for when injectQuery is called, and use that injector with runInInjectionContext so the developer could use inject inside these functions. It's very likely that almost any query will have DI dependencies (like HTTTP) and I believe the current implementation might make the DX a bit difficult.