summaryrefslogtreecommitdiffhomepage
path: root/app/lib
diff options
context:
space:
mode:
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/backend.js61
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);
+ }
+
+};