Closed wai-lin closed 2 years ago
After some consideration, I'm quite biased about this. Will giving the global context is a good thing? I think we should take lesson from the vue2
option api's mixin
problems. Especially for those who might be using turtle-express
in javascript
environment. Since they don't have type safety like typescript
users they may not notice the naming collisions. The worst about the global context is where to track the error from. For example if there is a context value used inside a resolver
is undefined or occur some kind of error, it'll be a context tracing hell (where the context is provided from).
I think just doing things the normal import
export
would be much nicer to trace back if something went wrong. Also users can just provide what they want from global
object if they wanted.
I think I won't be doing this feature for the time being since I did not convince myself enough to do this. I think the problems out weight the benefits the context
provide. Currently closing the issue.
Currently there's is a per handler context provider.
There's a need for global context provider via
createRouter()
function and alsorouter.path()
function for perpath
context provider.