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
The current implementation defines and uses a package-level variable for the *superTokens instance
which is not a great if anyone would like to have multiple instances or for testing (in parallel).
Instead it should be handled in encapsulation, for example by changing the func supertokensInit(config TypeInput) error {} and func Init(config TypeInput) error {} functions to return a *superTokens object and by making type superTokens struct {} a public struct:
Maybe Init(config TypeInput) should even be renamed to NewSuperTokens or NewSuperTokensInstnace.
To me this implementation is not very idiomatic Go and looks more like JavaScript.
This would probably a bigger change affecting various parts of the SDK.
Edit: After using the SDK a bit more, I've realized that almost every type has a singleton instance. This is not very flexible and definitely not a good design pattern. Basically all singletons should be removed and refactored with more structure in mind.
The text was updated successfully, but these errors were encountered:
The current implementation defines and uses a package-level variable for the
*superTokens
instancewhich is not a great if anyone would like to have multiple instances or for testing (in parallel).
Instead it should be handled in encapsulation, for example by changing the
func supertokensInit(config TypeInput) error {}
andfunc Init(config TypeInput) error {}
functions to return a*superTokens
object and by makingtype superTokens struct {}
a public struct:Maybe
Init(config TypeInput)
should even be renamed toNewSuperTokens
orNewSuperTokensInstnace
.To me this implementation is not very idiomatic Go and looks more like JavaScript.
This would probably a bigger change affecting various parts of the SDK.
Edit: After using the SDK a bit more, I've realized that almost every type has a singleton instance. This is not very flexible and definitely not a good design pattern. Basically all singletons should be removed and refactored with more structure in mind.
The text was updated successfully, but these errors were encountered: