This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
outline/frontend/stores/UiStore.js
2016-08-01 19:03:17 +03:00

33 lines
522 B
JavaScript

import { observable, action, computed } from 'mobx';
const UI_STORE = 'UI_STORE';
class UiStore {
@observable sidebar;
/* Computed */
@computed get asJson() {
return JSON.stringify({
sidebar: this.sidebar,
});
}
/* Actions */
@action toggleSidebar = () => {
this.sidebar = !this.sidebar;
};
constructor() {
// Rehydrate
const data = JSON.parse(localStorage.getItem(UI_STORE) || '{}');
this.sidebar = data.sidebar;
}
}
export default UiStore;
export {
UI_STORE,
};