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
@ldmarz
ldmarz / Filter.js
Created August 10, 2018 14:10
Example of Filter from lodash library
var users = [
{ firstName: "Ldmarz", lastName: "martinez", age: 28, gender: "male" },
{ firstName: "Suli", lastName: "bern", age: 5, gender: "female" },
{ firstName: "Marianis", lastName: "Carrey", age: 54, gender: "female" },
{ firstName: "Jhon", lastName: "carret", age: 40, gender: "male" }
];
var femaleUsers = _.filter(users, function(user) {
return user.gender === 'female'
});
@ldmarz
ldmarz / compact.js
Created August 10, 2018 14:15
example of compact function from lodash
const someDirtyArray = [0, 1, false, 2, '', 3];
const cleanedArray = _.compact(someDirtyArray);
// cleanedArray => [1, 2, 3]
<some-parent-component>
<button (click)="callChildFunction()" > call child function </button>
<some-child-component></some-child-component>
</some-parent-component>
import { Component, ViewChild } from '@angular/core';
import { SomeChildComponent } from './someChild/someChild.component';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
@ViewChild(SomeChildComponent) someChildComponent;
@ldmarz
ldmarz / app.js
Last active August 21, 2018 14:26
Example of lazy loaders on Angular
import { HomePage } from '../pages/home/home';
@NgModule({
declarations: [
MyApp,
HomePage
],
. . .
entryComponents: [
MyApp,
HomePage
@ldmarz
ldmarz / and.js
Last active August 23, 2018 19:51
Example how use fuse operators
const query = 'old man && scalzi';
const result = fuseWithOperators(query, mockData);
// → [{"title": "Old Man's War", "author": {"firstName": "John", "lastName": "Scalzi"}}]
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
})
import { GODOWN, GOUP, ELEMENTS } from '../actions.type';
const initialState = {
currentActive: 0,
elements: []
}
function listReducer(state = initialState, action) {
switch (action.type) {
case GODOWN:
import { GODOWN, GOUP, ELEMENTS} from '../actions.type';
function actionGoUp() {
return {
type: GODOWN
};
}
function actionGoDown() {
return {
export const GOUP = 'GOUP';
export const GODOWN = 'GODOWN';
export const ELEMENTS = 'ELEMENTS';