Skip to content

Instantly share code, notes, and snippets.

View franciscotln's full-sized avatar

Francisco Neto franciscotln

View GitHub Profile
import { Component } from '@angular/core';
import { ComButtonComponent } from '../../../../common/button';
import {
ComFormComponent,
ComFormGroupComponent,
ComFormInputComponent,
ComFormActionsComponent,
ComFormCheckboxComponent
} from '../../../../common/form';
import { ActivatedRoute } from '@angular/router';
@franciscotln
franciscotln / storage-driver.js
Created October 7, 2016 21:40
storageDriver for Cycle.js
import { ReplaySubject } from 'rxjs';
function StorageWrapper(storage) {
function set(key, value) {
storage.setItem(key, JSON.stringify(value));
return value;
}
function get(key) {
return JSON.parse(storage.getItem(key))
@franciscotln
franciscotln / example.js
Last active October 7, 2016 22:30
using storageDriver for Cycle.js
function main({ DOM, HTTP, storage }) {
const loginRequest$ = Observable.of({
category: 'tokens',
url: 'someUrl',
method: 'POST',
send: {
data: {
type: 'tokens',
attributes: {
email: 'some@email.io',
@franciscotln
franciscotln / checkboxes.js
Created October 19, 2016 00:26
using cyclejs
'use strict';
import { run } from '@cycle/rxjs-run';
import { makeDOMDriver, div, input, p, li, ul, span, h2, h5, label, hr } from '@cycle/dom';
import { makeHTTPDriver } from '@cycle/http';
import { Observable } from 'rxjs';
import isolate from '@cycle/isolate';
function intent(DOMSource) {
return DOMSource.select('.checkbox').events('click')
// why are you passing this 'currentStatus' from the view (first element in the array) if it's
// not being used here anywhere? You only use status and productId to dispatch the action;
// BTW: don't use array indices like arr[0], arr[1] ;-) that's not the reactive way.
this.onReject$
.switchMap(([currentStatus, status]: string[]): Observable<any> =>
this.product$.filter(Boolean).first().map((product: any) => {
const productId = product.get('id');
return { currentStatus, status, productId };
})
@franciscotln
franciscotln / mixins_and_composition.js
Last active February 25, 2017 16:26
mixins and composition
function compose(...fns) {
return arg => fns.reduceRight((prev, curr) => curr(prev), arg);
}
const fatherMixin = (BaseClass = class {}) =>
class Father extends BaseClass {
constructor() {
super()
this.frontendLang = 'JavaScript';
}
@franciscotln
franciscotln / all.elm
Created January 4, 2018 21:47
elixir-JS-elm
// Elixir
data = [
%{ id: 1, value: 0 },
%{ id: 2, value: 0 },
%{ id: 3, value: 0 }
]
Enum.map data, fn item ->
if item.id == 2 do
%{ item | value: item.value + 1 }
@franciscotln
franciscotln / scripts.js
Created January 29, 2018 23:25
controller factory, event delegation angularJs
angular
.module('myApp', [])
.factory('DataFactory', function DataFactory($q) {
return {
getData() {
return $q.when([
{id: 1, name: 'A'},
{id: 2, name: 'B'},
{id: 3, name: 'C'},
{id: 4, name: 'D'},
@franciscotln
franciscotln / stuff-type.tsx
Created January 30, 2018 00:37
no outside data
import * as React from 'react';
import * as R from 'ramda';
import { connect, Dispatch } from 'react-redux';
import { bindActionCreators } from 'redux';
import { Title } from '../../shared/components/title';
import { StuffTypeItems } from '../../shared/components/subscription-calculator';
import { Button } from '../../shared/components/button';
import { ItemComponent } from './stuff-type/item';
import { setStuffType, SubscriptionCalculatorActions } from '../store/subscription-calculator.actions';
import React from 'react';
const ListWrapper = ({ children }) => (
<div className='people-list-wrapper'>
<ul className='people-list'>
{children}
</ul>
</div>
);