diff options
| author | Andrej Mihajlov <and@codeispoetry.ru> | 2017-02-10 20:40:54 +0000 |
|---|---|---|
| committer | Andrej Mihajlov <and@codeispoetry.ru> | 2017-02-10 20:40:54 +0000 |
| commit | 6fe70786242de8aae0d592f658ace0624a369685 (patch) | |
| tree | ac92d603a2bf72c94d5082f52ddedf4b3177b703 /app/lib | |
| parent | 036da86805c8c09edabeb116ad2d682e061a6e60 (diff) | |
| download | mullvadvpn-6fe70786242de8aae0d592f658ace0624a369685.tar.xz mullvadvpn-6fe70786242de8aae0d592f658ace0624a369685.zip | |
Add backend mockup and wire it up with all components
Diffstat (limited to 'app/lib')
| -rw-r--r-- | app/lib/backend.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/app/lib/backend.js b/app/lib/backend.js new file mode 100644 index 0000000000..33194c4325 --- /dev/null +++ b/app/lib/backend.js @@ -0,0 +1,61 @@ +import privateData from './private'; + +/** + * Private data + */ +const { get: getImpl, set: setImpl } = privateData(); + +/** + * Remote backend implementation + * + * @class BackendImpl + */ +class BackendImpl { + constructor() { + this._account = null; + this._loggedIn = false; + } + + get account() { + return this._account; + } + + get loggedIn() { + return this._loggedIn; + } + + login(account) { + return new Promise((resolve, reject) => { + // @TODO: Add login call + setTimeout(() => { + reject(new Error("Invalid account number.")); + }, 2000); + }); + } +} + +/** + * Backend implementation + * + * @export + * @class Backend + */ +export default class Backend { + + constructor() { + setImpl(this, new BackendImpl()); + } + + get account() { + return getImpl(this).account; + } + + get loggedIn() { + return getImpl(this).loggedIn; + } + + login(account) { + return getImpl(this).login(account); + } + +}; |
