This file contains hidden or 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
| const query = 'old man || artist'; | |
| const result = fuseWithOperators(query, mockData); | |
| // → [{"title": "Old Man's War", "author": {"firstName": "John", "lastName": "Scalzi"}}, {"title": "The Lock Artist", "author": {"firstName": "John", "lastName": "Hamilton"}}] |
This file contains hidden or 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
| const query = 'old man && scalzi'; | |
| const result = fuseWithOperators(query, mockData); | |
| // → [{"title": "Old Man's War", "author": {"firstName": "John", "lastName": "Scalzi"}}] |
This file contains hidden or 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
| // Data example | |
| const mockData = [ | |
| { | |
| "title": "Old Man's War", | |
| "author": { | |
| "firstName": "John", | |
| "lastName": "Scalzi" | |
| } | |
| }, | |
| { |
This file contains hidden or 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
| $ npm i fuse-operators |
This file contains hidden or 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
| goUpIndex() { | |
| this.$ngRedux.dispatch({ type: GOUP}); | |
| } | |
| setElements(elements) { | |
| this.$ngRedux.dispatch({ type: ELEMENTS, elements }); | |
| } | |
| goDownIndex() { | |
| this.$ngRedux.dispatch({ type: GODOWN }); |
This file contains hidden or 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
| constructor($ngRedux) { | |
| 'ngInject'; | |
| this.$ngRedux = $ngRedux; | |
| $ngRedux.connect(this.mapStateToThis, actions)(this); | |
| } | |
| mapStateToThis(state) { | |
| return { | |
| currentActive: state.listReducer.currentActive | |
| }; |
This file contains hidden or 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
| export const GOUP = 'GOUP'; | |
| export const GODOWN = 'GODOWN'; | |
| export const ELEMENTS = 'ELEMENTS'; |
This file contains hidden or 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
| import { GODOWN, GOUP, ELEMENTS} from '../actions.type'; | |
| function actionGoUp() { | |
| return { | |
| type: GODOWN | |
| }; | |
| } | |
| function actionGoDown() { | |
| return { |
This file contains hidden or 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
| import { GODOWN, GOUP, ELEMENTS } from '../actions.type'; | |
| const initialState = { | |
| currentActive: 0, | |
| elements: [] | |
| } | |
| function listReducer(state = initialState, action) { | |
| switch (action.type) { | |
| case GODOWN: |
This file contains hidden or 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
| import ngRedux from 'ng-redux'; | |
| import { combineReducers } from 'redux'; // Usefull function to combine multiple reducers | |
| import reducers from './redux/reducers/'; | |
| angular | |
| .module('app', [ngRedux]) | |
| .config(($ngReduxProvider) => { | |
| let reducer = combineReducers(reducers); | |
| $ngReduxProvider.createStoreWith(reducer); // Aditionally here we can add middlewares like redux-logger | |
| }) |