summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-core/src/models/StateApi.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2017-02-17 19:01:28 +0100
committerSamy Pessé <samypesse@gmail.com>2017-02-17 19:01:28 +0100
commit21884d80c311ee7888d4a59c19423643b798d29a (patch)
tree25357f7a320b3702d0b3f9cc01f381a495925751 /packages/gitbook-core/src/models/StateApi.js
parent4e3e3e515de5da4a9926ccae38256381f2a32714 (diff)
downloadgitbook-21884d80c311ee7888d4a59c19423643b798d29a.zip
gitbook-21884d80c311ee7888d4a59c19423643b798d29a.tar.gz
gitbook-21884d80c311ee7888d4a59c19423643b798d29a.tar.bz2
Define actions for low level gitbook.com API
Diffstat (limited to 'packages/gitbook-core/src/models/StateApi.js')
-rw-r--r--packages/gitbook-core/src/models/StateApi.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/packages/gitbook-core/src/models/StateApi.js b/packages/gitbook-core/src/models/StateApi.js
new file mode 100644
index 0000000..430833b
--- /dev/null
+++ b/packages/gitbook-core/src/models/StateApi.js
@@ -0,0 +1,26 @@
+const { Record } = require('immutable');
+
+const DEFAULTS = {
+ currentUser: null
+};
+
+/**
+ * State for the API, it stores informations about the logged in user, etc.
+ * @type {Record}
+ */
+class StateApi extends Record(DEFAULTS) {
+ static create(state) {
+ return state instanceof StateApi ?
+ state : new StateApi(state);
+ }
+
+ /**
+ * Check if reader is an user is loggedin.
+ * @return {Boolean}
+ */
+ get isLoggedIn() {
+ return Boolean(this.currentUser);
+ }
+}
+
+module.exports = StateApi;