-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow referencing of overrided function by original implementation #199
Labels
bug
Something isn't working
Comments
rishabhpoddar
pushed a commit
to supertokens/supertokens-auth-react
that referenced
this issue
Oct 28, 2021
rishabhpoddar
pushed a commit
to supertokens/supertokens-website
that referenced
this issue
Oct 28, 2021
rishabhpoddar
pushed a commit
to supertokens/supertokens-react-native
that referenced
this issue
Oct 28, 2021
Issue two fix for nodejs: 8a4afbb |
rishabhpoddar
pushed a commit
to supertokens/supertokens-golang
that referenced
this issue
Oct 30, 2021
rishabhpoddar
pushed a commit
to supertokens/supertokens-auth-react
that referenced
this issue
Oct 30, 2021
This was referenced Oct 31, 2021
Merged
rishabhpoddar
pushed a commit
to supertokens/supertokens-auth-react
that referenced
this issue
Nov 5, 2021
rishabhpoddar
pushed a commit
to supertokens/supertokens-react-native
that referenced
this issue
Nov 5, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Right now, if the original implementation has a function
A
, which calls another functionB
, and then if the user overrides functionB
and then ifA
is called, it does not call user'sB
, but instead calls the originalB
.This would break logic in many cases. At the moment, this affects the JS SDKs and the golang SDK.
JS fix (node, auth-react, website, react-native SDKs):
The trick here is to not use arrow functions for any of the functions in the recipe / api interface implementaiton. This allows the
this
variable to point to functions in the new object returned by the user solving this problem.Then when the user calls the original function, they must bind it to
this
object as shown below.Small example:
Golang fix:
The trick here is to make all the recipe / api interface functions pointers to functions, and then get the user to change the pointer value when overriding it like so:
SignUp
is a pointer to the actual sign up function, andSignIn
is a pointer to the actual sign in function.TODO:
get
functionAnother important issue:
Here is the situation:
Now if a user creates an instance of
Recipe2
, and then overridessomeFunc3
to do what they like (and semantically someFunc3 is similar to someFunc2), calling recipe2.someFunc() will not have the same expected behaviour.The text was updated successfully, but these errors were encountered: