|
4 | 4 | */
|
5 | 5 | 'use strict';
|
6 | 6 | var createStore = require('fluxible/addons').createStore;
|
7 |
| -var routesConfig= require('../configs/routes') |
8 | 7 |
|
9 | 8 | var ApplicationStore = createStore({
|
10 | 9 | storeName: 'ApplicationStore',
|
11 | 10 | handlers: {
|
12 |
| - 'CHANGE_ROUTE_SUCCESS' : 'handleNavigate', |
13 | 11 | 'UPDATE_PAGE_TITLE' : 'updatePageTitle'
|
14 | 12 | },
|
15 | 13 | initialize: function () {
|
16 |
| - this.currentPageName = null; |
17 |
| - this.currentPage = null; |
18 |
| - this.currentRoute = null; |
19 |
| - this.pages = routesConfig; |
20 | 14 | this.pageTitle = '';
|
21 | 15 | },
|
22 |
| - handleNavigate: function (route) { |
23 |
| - if (this.currentRoute && (this.currentRoute.url === route.url)) { |
24 |
| - return; |
25 |
| - } |
26 |
| - |
27 |
| - var pageName = route.config.page; |
28 |
| - var page = this.pages[pageName]; |
29 |
| - |
30 |
| - this.currentPageName = pageName; |
31 |
| - this.currentPage = page; |
32 |
| - this.currentRoute = route; |
| 16 | + updatePageTitle: function (payload) { |
| 17 | + this.pageTitle = payload.pageTitle; |
33 | 18 | this.emitChange();
|
34 | 19 | },
|
35 |
| - updatePageTitle: function (title) { |
36 |
| - this.pageTitle = title.pageTitle; |
37 |
| - this.emitChange(); |
38 |
| - }, |
39 |
| - getCurrentPageName: function () { |
40 |
| - return this.currentPageName; |
41 |
| - }, |
42 | 20 | getPageTitle: function () {
|
43 | 21 | return this.pageTitle;
|
44 | 22 | },
|
45 | 23 | getState: function () {
|
46 | 24 | return {
|
47 |
| - currentPageName: this.currentPageName, |
48 |
| - currentPage: this.currentPage, |
49 |
| - pages: this.pages, |
50 |
| - route: this.currentRoute, |
51 | 25 | pageTitle: this.pageTitle
|
52 | 26 | };
|
53 | 27 | },
|
54 | 28 | dehydrate: function () {
|
55 | 29 | return this.getState();
|
56 | 30 | },
|
57 | 31 | rehydrate: function (state) {
|
58 |
| - this.currentPageName = state.currentPageName; |
59 |
| - this.currentPage = state.currentPage; |
60 |
| - this.pages = state.pages; |
61 |
| - this.currentRoute = state.route; |
62 | 32 | this.pageTitle = state.pageTitle;
|
63 | 33 | }
|
64 | 34 | });
|
|
0 commit comments