-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
14 changed files
with
145 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Design | ||
|
||
## Navigation history | ||
|
||
### At First time | ||
|
||
1. If has not `?text={query}`, return | ||
2. fill with `{query}` and analyzed | ||
|
||
In other word, | ||
|
||
1. Separate save data and change url. | ||
|
||
### Typing | ||
|
||
1. Analyze `{query}` and output result | ||
1. Set `{query}` to navigation `?text={query}` |
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
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,16 +1,21 @@ | ||
// LICENSE : MIT | ||
"use strict"; | ||
const React = require("react"); | ||
const parse = require("query-string").parse; | ||
import App from "./App/App" | ||
import AppLocator from "../../AppLocator"; | ||
import LoadingContainer from "../ui-kit/LoadingContainer/LoadingContainer"; | ||
import InitializeUseCase from "../../js/use-case/InitializeUseCase"; | ||
import ChangeURLStateUseCase from "../../js/use-case/routing/ChangeURLStateUseCase"; | ||
const AppLoading = LoadingContainer(App); | ||
export default class AppBootStrap extends React.Component { | ||
render() { | ||
const hashString = location.hash.slice(1); | ||
const hash = hashString ? decodeURIComponent(hashString) : undefined; | ||
const promise = AppLocator.context.useCase(InitializeUseCase.create()).execute({hash}); | ||
const location = AppLocator.history.getCurrentLocation(); | ||
const query = parse(location.search); | ||
const context = AppLocator.context; | ||
const promise = context.useCase(InitializeUseCase.create()).execute({text: query.text}).catch(error => { | ||
console.error(error); | ||
}); | ||
return <AppLoading promise={promise}/>; | ||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// LICENSE : MIT | ||
"use strict"; | ||
import ReduceState from "../base/ReduceState"; | ||
import ChangeURLStateUseCase from "../../use-case/routing/ChangeURLStateUseCase"; | ||
export default class RoutingState extends ReduceState { | ||
constructor({query} = {}) { | ||
super(); | ||
const queryObject = query || {}; | ||
this.text = queryObject.text; | ||
} | ||
|
||
reduce(payload) { | ||
switch (payload.type) { | ||
case ChangeURLStateUseCase.Events.change: | ||
return new RoutingState(Object.assign({}, this, { | ||
query: payload.query | ||
})); | ||
default: | ||
return this; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// LICENSE : MIT | ||
"use strict"; | ||
import ReduceStore from "../base/ReduceStore"; | ||
import RoutingState from "./RoutingState"; | ||
export default class RoutingStore extends ReduceStore { | ||
constructor() { | ||
super(); | ||
this.state = new RoutingState(); | ||
this.onDispatch(payload => { | ||
this.setState(this.state.reduce(payload)); | ||
}); | ||
} | ||
|
||
getState() { | ||
return { | ||
routing: this.state | ||
}; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// LICENSE : MIT | ||
"use strict"; | ||
import {UseCase} from 'almin'; | ||
/** | ||
* Change URL Query for preserve state | ||
*/ | ||
export default class ChangeURLStateUseCase extends UseCase { | ||
static create() { | ||
return new this(); | ||
} | ||
|
||
execute(query) { | ||
this.dispatch({ | ||
type: ChangeURLStateUseCase.Events.change, | ||
query: query | ||
}); | ||
} | ||
|
||
} | ||
ChangeURLStateUseCase.Events = { | ||
change: "ChangeURLStateUseCase" | ||
}; |