-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
771 additions
and
785 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
export { default as useConnect } from "./useConnect"; | ||
export { default as ReduceStore } from "./ReduceStore"; | ||
export { default as ImmutableStore, Map, Set, getMap, mergeMap } from "./ImmutableStore"; | ||
export { | ||
default as ImmutableStore, | ||
Map, | ||
Set, | ||
getMap, | ||
mergeMap, | ||
} from "./ImmutableStore"; | ||
export { default as getStores } from "./getStores"; | ||
export { Dispatcher } from "reshow-flux-base"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,11 @@ | ||
import { ReduceStore } from "reshow-flux"; | ||
import { createReducer } from "reshow-flux-base"; | ||
import get from "get-object-value"; | ||
import { localStorage, Storage } from "get-storage"; | ||
|
||
import storageDispatcher from "../storageDispatcher"; | ||
const [store, localDispatch] = createReducer((state, action) => { | ||
const params = get(action, ["params"]); | ||
return state.merge(params); | ||
}, new Storage(localStorage)); | ||
|
||
class LocalStorageStore extends ReduceStore { | ||
getInitialState() { | ||
return new Storage(localStorage); | ||
} | ||
|
||
updateStorage(state, action) { | ||
const params = get(action, ["params"]); | ||
return state.merge(params); | ||
} | ||
|
||
reduce(state, action) { | ||
switch (action.type) { | ||
case "local": | ||
return this.updateStorage(state, action); | ||
default: | ||
return state; | ||
} | ||
} | ||
} | ||
|
||
export default new LocalStorageStore(storageDispatcher); | ||
|
||
export { LocalStorageStore }; | ||
export default store; | ||
export { localDispatch }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,41 @@ | ||
import { ReduceStore } from "reshow-flux"; | ||
import dispatcher from "../dispatcher"; | ||
import { ImmutableStore, mergeMap } from "reshow-flux"; | ||
import { KEYS } from "reshow-constant"; | ||
import { realTimeDispatch } from "./realTimeStore"; | ||
import { messageDispatch } from "./messageStore"; | ||
import { sessionDispatch } from "./sessionStorageStore"; | ||
import { localDispatch } from "./localStorageStore"; | ||
|
||
const keys = Object.keys; | ||
|
||
class PageStore extends ReduceStore { | ||
reduce(state, action) { | ||
switch (action.type) { | ||
case "config/set": | ||
return state.merge(action.params); | ||
case "config/reset": | ||
return state.clear().merge(action.params); | ||
case "realTime": | ||
const [store, dispatch] = ImmutableStore((state, action) => { | ||
switch (action.type) { | ||
case "dialog/start": | ||
case "dialog/end": | ||
case "alert/reset": | ||
case "alert/del": | ||
case "alert/add": | ||
messageDispatch(action); | ||
return state; | ||
case "realTime": | ||
realTimeDispatch(action); | ||
return state; | ||
case "local": | ||
localDispatch(action); | ||
return state; | ||
case "session": | ||
sessionDispatch(action); | ||
return state; | ||
case "config/set": | ||
return mergeMap(state, action.params); | ||
case "config/reset": | ||
return mergeMap(state.clear(), action.params); | ||
return state.clear().merge(action.params); | ||
default: | ||
if (KEYS(action)) { | ||
return mergeMap(state, action); | ||
} else { | ||
return state; | ||
default: | ||
if (keys(action)) { | ||
return state.merge(action); | ||
} else { | ||
return state; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
|
||
// Export a singleton instance of the store | ||
export default new PageStore(dispatcher); | ||
export default store; | ||
export { dispatch }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,13 @@ | ||
"use strict"; | ||
import { ImmutableStore } from "reshow-flux"; | ||
|
||
import { ReduceStore } from "reshow-flux"; | ||
import dispatcher from "../dispatcher"; | ||
|
||
class RealTimeStore extends ReduceStore { | ||
reduce(state, action) { | ||
switch (action.type) { | ||
case "realTime": | ||
return action.params; | ||
default: | ||
return []; | ||
} | ||
const [store, realTimeDispatch] = ImmutableStore((state, action) => { | ||
switch (action.type) { | ||
case "realTime": | ||
return action.params; | ||
default: | ||
return []; | ||
} | ||
} | ||
}); | ||
|
||
export default new RealTimeStore(dispatcher); | ||
export default store; | ||
export { realTimeDispatch }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,11 @@ | ||
import { createReducer } from "reshow-flux-base"; | ||
import get from "get-object-value"; | ||
import { sessionStorage, Storage } from "get-storage"; | ||
|
||
import { LocalStorageStore } from "./localStorageStore"; | ||
import storageDispatcher from "../storageDispatcher"; | ||
const [store, sessionDispatch] = createReducer((state, action) => { | ||
const params = get(action, ["params"]); | ||
return state.merge(params); | ||
}, new Storage(sessionStorage)); | ||
|
||
class SessionStorageStore extends LocalStorageStore { | ||
getInitialState() { | ||
return new Storage(sessionStorage); | ||
} | ||
|
||
reduce(state, action) { | ||
switch (action.type) { | ||
case "session": | ||
return this.updateStorage(state, action); | ||
default: | ||
return state; | ||
} | ||
} | ||
} | ||
|
||
export default new SessionStorageStore(storageDispatcher); | ||
export default store; | ||
export { sessionDispatch }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.