Closed bigtimebuddy closed 4 years ago
Thanks for putting this together Matt, I really appreciate it.
I'm OK starting with the simplicity of just a list of resolvers. I do think we should just make the API be an array always though. Otherwise the usage for a user who wants to add a resolver involves checking if it an array or not before adding theirs. It would be easier to just always be an array so anyone can just push onto it.
One other piece of feedback, is I'd also rather hide it behind a function that adds a resolver. That way if down the road we want to add priority or something like middleware, we can do it in a backwards compatible way (add a param) rather than switch to a function at that time and do weird gymnastics to make an array property work. Maybe just addUrlResolver
and make the property private?
Sounds good and agreed. I can adjust this to accommodate that feedback.
Okay I removed urlResolver
and replaced with a addUrlResolver
method that takes the function as a single argument.
Changed
urlResolver
function can now be a single function or a collection of functionsurlResolver
functionsI tried to keep the API as simple as possible and this is probably the most conservative approach, however, but I think it could also make sense to have a
resolve
function that works likeuse
and internally the loader maintains instances.Whatever you think is best.