anvil-works / routing

routing - Built with Anvil
https://routing-docs.anvil.works
MIT License
2 stars 1 forks source link

loader_deps is confusing #8

Closed s-cork closed 2 months ago

s-cork commented 2 months ago

I think the api is required, but because the non-caching version seemingly behaves differently, it would be worth adjusting.

naming:

I like cache_deps because we will always cache by the path, and then by whatever is returned form cache_deps

By default we could return the query

Route:
    def cache_deps(self, **loader_args):
        return loader_args["query"]

i.e. forms/data are cached by the path and the query by default

And then if you want to override this you can

MyRoute(Route):
    cache_form = True

    def cache_deps(self, **loader_args):
        return None

In this case MyRoute will create a new form instance whenever the query changes


tagging @daviesian for opinion