-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Reusable Accounts constructors #4233
Conversation
this._initLocalStorage(); | ||
}; | ||
|
||
var Ap = AccountsClient.prototype = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This inheritance dance will become much cleaner when we enable ES6 class syntax in core packages.
433df8f
to
a608173
Compare
There's an argument in favor of making |
This involves moving Accounts.* methods defined in accounts_common.js onto AccountsCommon.prototype.*.
Note that this constructor inherits from the AccountsCommon constructor. Naturally both of these constructor functions should become classes once we have support for ES6 classes.
There's an argument in favor of making AccountsClient available on both client and server, since server code might need to act as a client to an accounts server, too. I don't need that functionality yet, but it's something to think about.
Also share urls.* methods between all AccountsServer instances.
aaa4309
to
a2d588d
Compare
Closed via ff5fb16. |
This pull requests reduces the assumption of a singleton
Accounts
namespace in theaccounts-base
core package, making it much easier to manage multiple accounts connections without duplicating code.At a high level, this refactoring was all about replacing the ad-hoc
Accounts
object with instances of the newAccountsClient
andAccountsServer
classes, which inherit fromAccountsCommon
so that methods can be shared (yay isomorphism!).As an example of a luxury that had to be given up in order to support multiple accounts instances, initialization code that used to run at the top level (like the auto-login code) is now called from the constructor functions.
I think it's now much clearer which methods and properties are available on the client, on the server, or in both places, since each environment has a distinct
.prototype
where available methods are defined.