diff options
author | Samy Pesse <samypesse@gmail.com> | 2016-10-03 10:35:24 +0200 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2016-10-03 10:35:24 +0200 |
commit | 34eb35699d951783837faf026a60abadc888a010 (patch) | |
tree | 6cc3f941ca76b7f32329f6c110fe45374d7dfc99 /packages/gitbook-plugin-search | |
parent | 3ae72bb47c146212d40fc74d857880fa0616ae57 (diff) | |
download | gitbook-34eb35699d951783837faf026a60abadc888a010.zip gitbook-34eb35699d951783837faf026a60abadc888a010.tar.gz gitbook-34eb35699d951783837faf026a60abadc888a010.tar.bz2 |
Change "init to "activate"
Diffstat (limited to 'packages/gitbook-plugin-search')
-rw-r--r-- | packages/gitbook-plugin-search/src/actions/search.js | 9 | ||||
-rw-r--r-- | packages/gitbook-plugin-search/src/index.js | 7 |
2 files changed, 14 insertions, 2 deletions
diff --git a/packages/gitbook-plugin-search/src/actions/search.js b/packages/gitbook-plugin-search/src/actions/search.js index b4f811e..c71eda2 100644 --- a/packages/gitbook-plugin-search/src/actions/search.js +++ b/packages/gitbook-plugin-search/src/actions/search.js @@ -2,6 +2,14 @@ const { Promise, Immutable } = require('gitbook-core'); const { List } = Immutable; const TYPES = require('./types'); +/* + Search workflow: + + 1. Typing in the search input + 2. Trigger an update of the url + 3. An update of the url, trigger an update of search results + */ + /** * Start a search query * @param {String} q @@ -13,7 +21,6 @@ function query(q) { }; } - /** * Update results for a query * @param {String} q diff --git a/packages/gitbook-plugin-search/src/index.js b/packages/gitbook-plugin-search/src/index.js index 05c2056..bc6c406 100644 --- a/packages/gitbook-plugin-search/src/index.js +++ b/packages/gitbook-plugin-search/src/index.js @@ -5,6 +5,11 @@ const SearchResults = require('./components/Results'); const reducers = require('./reducers'); const Search = require('./actions/search'); +/** + * Url of the page changed, we update the search according to this. + * @param {GitBook.Location} location + * @param {Function} dispatch + */ const onLocationChange = (location, dispatch) => { const { query } = location; const q = query.get('q'); @@ -13,7 +18,7 @@ const onLocationChange = (location, dispatch) => { }; module.exports = GitBook.createPlugin({ - init: (dispatch, getState, { Navigation, Components }) => { + activate: (dispatch, getState, { Navigation, Components }) => { // Register the navigation handler dispatch(Navigation.listen(onLocationChange)); |