-
Notifications
You must be signed in to change notification settings - Fork 176
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 creating instances #82
Comments
Hi, I agree that using graph.get('/me', { access_token: "..." }, cb) Global |
That's fair. I'll create a thin wrapper around it that just ensures an access token is provided (for type checks). It seems @criso isn't very active currently so I'll just leave this open for now. Thanks for the tip. |
Sorry guys, it's been a crazy week and I wanted to let this marinate for a bit to see how everyone else feels about it. Using objects for this seems like the same thing as creating a new If you're building requests for 10 different users, would you keep those in a pool ? How would you free up those objects later on? I'm wondering about things like that |
It would be a very good feature. For example in one project I need to use multiple graph versions - now I am unable to do so. |
+1 for adding this. If my app is doing stuff with the graph API for multiple users at once, it looks like the executions will happen on behalf of whatever User's token was passed to
As mentioned by another comment, setting the token before each call is not really a great solution as it's prone to forgetfulness and is painfully verbose. As-is, this will cause a few things to happen:
Thanks for the work on this so far! |
no progress here :( |
For anyone who needs this, there is an elegant solution for this. I like the simplicity of this library, so I created a es6 class around this library and passed the access_token in the constructor. Like this:
Then, you can create instances of this class with different access tokens. I did this with es6 classes but the same can be achieved with prototype functions. |
The idea is to maintain compatibility, but move all of the module level variables to instance properties.
This allows prototypical inheritance so that the setters don't affect other areas of the code. This basically shows the use case. Also... it's just bug prone to be calling these setX functions before every request.
The text was updated successfully, but these errors were encountered: