Skip to content

Instantly share code, notes, and snippets.

View ldmarz's full-sized avatar
💯
Dandolo todo mientras me divierto

Lenin martinez ldmarz

💯
Dandolo todo mientras me divierto
View GitHub Profile
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"}}]
const query = 'old man && scalzi';
const result = fuseWithOperators(query, mockData);
// → [{"title": "Old Man's War", "author": {"firstName": "John", "lastName": "Scalzi"}}]
// Data example
const mockData = [
{
"title": "Old Man's War",
"author": {
"firstName": "John",
"lastName": "Scalzi"
}
},
{
$ npm i fuse-operators
goUpIndex() {
this.$ngRedux.dispatch({ type: GOUP});
}
setElements(elements) {
this.$ngRedux.dispatch({ type: ELEMENTS, elements });
}
goDownIndex() {
this.$ngRedux.dispatch({ type: GODOWN });
constructor($ngRedux) {
'ngInject';
this.$ngRedux = $ngRedux;
$ngRedux.connect(this.mapStateToThis, actions)(this);
}
mapStateToThis(state) {
return {
currentActive: state.listReducer.currentActive
};
export const GOUP = 'GOUP';
export const GODOWN = 'GODOWN';
export const ELEMENTS = 'ELEMENTS';
import { GODOWN, GOUP, ELEMENTS} from '../actions.type';
function actionGoUp() {
return {
type: GODOWN
};
}
function actionGoDown() {
return {
import { GODOWN, GOUP, ELEMENTS } from '../actions.type';
const initialState = {
currentActive: 0,
elements: []
}
function listReducer(state = initialState, action) {
switch (action.type) {
case GODOWN:
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
})