blob: 3347c46331c44dedaadfcdf0127a0c42cc87127b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
const { Record } = require('immutable');
const DEFAULTS = {
// Is the API accessible for this book ? (Is the book on GitBook.com)
isAvailable: false,
// Current gitbook.com ready the book
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;
|